From: david
Subject: please review my code
Date: 
Message-ID: <8259823f-5ba2-4d71-a1b1-85c4ffb44d77@v42g2000yqj.googlegroups.com>
please for suggestions on how to learn programming, improve my code,
have better cl style,
and become a comp.lang.lisp hero. or just say my code sucks and/or i'm
an idiot. i welcome
all input. feelings are stupid.
thanks, david

(defun random-position () (1+ (random 64)))                       ;
this looks much nicer in emacs

(defun get-positions ()
  (loop
     :with results = '()
     :for alea = (random-position)
     :while (< (length results) 4)
     :do (pushnew alea results)
     :finally (return results)))

(defun rank-file (position)
  (mapcar (function 1+) (multiple-value-list (truncate (1- position)
8))))

(defparameter wk (rank-file (first (get-positions))))
(defparameter wb (rank-file (second (get-positions))))
(defparameter wn (rank-file (third (get-positions))))
(defparameter bk (rank-file (fourth (get-positions))))

(defparameter fenlist
  (make-list 8 :initial-element (make-list 8 :initial-element 0)))

(defparameter column (make-list 8 :initial-element 0))

(defun set-col (position piece)
  (case position
    ((1)(setf (first column) piece))
    ((2)(setf (second column) piece))
    ((3)(setf (third column) piece))
    ((4)(setf (fourth column) piece))
    ((5)(setf (fifth column) piece))
    ((6)(setf (sixth column) piece))
    ((7)(setf (seventh column) piece))
    ((8)(setf (eighth column) piece))))


(defun set-row (row)
	   (case row
	     ((1)(setf (first fenlist) column))
	     ((2)(setf (second fenlist) column))
	     ((3)(setf (third fenlist) column))
	     ((4)(setf (fourth fenlist) column))
	     ((5)(setf (fifth fenlist) column))
	     ((6)(setf (sixth fenlist) column))
	     ((7)(setf (seventh fenlist) column))
	     ((8)(setf (eighth fenlist) column))))

(defun make-fen (row col piece)
	   (set-col col piece)
	   (set-row row))

From: Barry Margolin
Subject: Re: please review my code
Date: 
Message-ID: <barmar-CF44B8.20563918022009@mara100-84.onlink.net>
In article 
<····································@v42g2000yqj.googlegroups.com>,
 david <······@gmail.com> wrote:

> please for suggestions on how to learn programming, improve my code,
> have better cl style,
> and become a comp.lang.lisp hero. or just say my code sucks and/or i'm
> an idiot. i welcome
> all input. feelings are stupid.
> thanks, david

One thing that would help would be if you explained what your program is 
supposed to be doing.  I guess it's doing something with a checkerboard, 
because there are lots of 8x8 things, but other than that I can't figure 
out what all these things represent.

> 
> (defun random-position () (1+ (random 64)))                       ;
> this looks much nicer in emacs
> 
> (defun get-positions ()
>   (loop
>      :with results = '()
>      :for alea = (random-position)
>      :while (< (length results) 4)
>      :do (pushnew alea results)
>      :finally (return results)))
> 
> (defun rank-file (position)
>   (mapcar (function 1+) (multiple-value-list (truncate (1- position)
> 8))))

Nobody spells out FUNCTION like this, use #'1+.  Although creating the 
list and then MAPCARing when you know it's always just two items seems 
wrong to me.  I'd write:

(defun rank-file (position)
  (multiple-value-bind (quotient remainder)
                       (truncate (1- position) 8)
    (list (1+ quotient) (1+ remainder))))

It also seems like you do lots of incrementing and subtracting, just to 
deal with the fact that your positions are 1-based.  If you used 0-based 
positions, wouldn't this all go away?

> 
> (defparameter wk (rank-file (first (get-positions))))
> (defparameter wb (rank-file (second (get-positions))))
> (defparameter wn (rank-file (third (get-positions))))
> (defparameter bk (rank-file (fourth (get-positions))))

Each time you call GET-POSITIONS it creates a new list of 4 random 
numbers.  So these four variables will not be the elements of one 
position list, they'll each be a different element of a different list.  
I doubt this is what you wanted.  What you probably want is something 
like this:

(defvar wk)
(defvar wb)
(defvar wn)
(defvar bk)

(destructuring-bind (wk-temp wb-temp wn-temp bk-temp)
                    (get-positions)
  (setq wk (rank-file wk-temp)
        wb (rank-file wb-temp)
        wn (rank-file wn-temp)
        bk (rank-file wn-temp)))

> 
> (defparameter fenlist
>   (make-list 8 :initial-element (make-list 8 :initial-element 0)))

This will use the same list for all elements of fenlist, which is 
probably not what you want.

(defparameter fenlist
  (loop repeat 8
     collect (make-list 8 :initial-element 0)))

Is there a reason why you're using a list of lists instead of an 8x8 
array?

> 
> (defparameter column (make-list 8 :initial-element 0))
> 
> (defun set-col (position piece)
>   (case position
>     ((1)(setf (first column) piece))
>     ((2)(setf (second column) piece))
>     ((3)(setf (third column) piece))
>     ((4)(setf (fourth column) piece))
>     ((5)(setf (fifth column) piece))
>     ((6)(setf (sixth column) piece))
>     ((7)(setf (seventh column) piece))
>     ((8)(setf (eighth column) piece))))

Wow, that's incresibly weird.  Don't you think the computer knows how to 
count to the place to fill in?

(defun set-col (position piece)
  (setf (nth (1- position) column) piece))

Again, using 1-based positions forces a decrement.  Zero-based counting 
generally makes life easier.

> 
> 
> (defun set-row (row)
> 	   (case row
> 	     ((1)(setf (first fenlist) column))
> 	     ((2)(setf (second fenlist) column))
> 	     ((3)(setf (third fenlist) column))
> 	     ((4)(setf (fourth fenlist) column))
> 	     ((5)(setf (fifth fenlist) column))
> 	     ((6)(setf (sixth fenlist) column))
> 	     ((7)(setf (seventh fenlist) column))
> 	     ((8)(setf (eighth fenlist) column))))

This should be rewritten similarly to set-col.  I'm also not sure what 
you're doing in this function.  Do you realize that this won't copy 
column -- whenever you call this, the specified row will be a reference 
to the same column list as other rows that have been set this way.

> 
> (defun make-fen (row col piece)
> 	   (set-col col piece)
> 	   (set-row row))

-- 
Barry Margolin, ······@alum.mit.edu
Arlington, MA
*** PLEASE post questions in newsgroups, not directly to me ***
*** PLEASE don't copy me on replies, I'll read them in the group ***
From: Pascal J. Bourguignon
Subject: Re: please review my code
Date: 
Message-ID: <87skmbji9s.fsf@galatea.local>
Barry Margolin <······@alum.mit.edu> writes:
>> (defun rank-file (position)
>>   (mapcar (function 1+) (multiple-value-list (truncate (1- position)
>> 8))))
>
> Nobody spells out FUNCTION like this, use #'1+.  

I do.  I find it smoother than sharp and little bits in the eyes.


-- 
__Pascal Bourguignon__
From: Barry Margolin
Subject: Re: please review my code
Date: 
Message-ID: <barmar-B02962.21091218022009@mara100-84.onlink.net>
In article <··············@galatea.local>,
 ···@informatimago.com (Pascal J. Bourguignon) wrote:

> Barry Margolin <······@alum.mit.edu> writes:
> >> (defun rank-file (position)
> >>   (mapcar (function 1+) (multiple-value-list (truncate (1- position)
> >> 8))))
> >
> > Nobody spells out FUNCTION like this, use #'1+.  
> 
> I do.  I find it smoother than sharp and little bits in the eyes.

Do you also spell out QUOTE?

-- 
Barry Margolin, ······@alum.mit.edu
Arlington, MA
*** PLEASE post questions in newsgroups, not directly to me ***
*** PLEASE don't copy me on replies, I'll read them in the group ***
From: Pascal J. Bourguignon
Subject: Re: please review my code
Date: 
Message-ID: <87hc2rjg4e.fsf@galatea.local>
Barry Margolin <······@alum.mit.edu> writes:

> In article <··············@galatea.local>,
>  ···@informatimago.com (Pascal J. Bourguignon) wrote:
>
>> Barry Margolin <······@alum.mit.edu> writes:
>> >> (defun rank-file (position)
>> >>   (mapcar (function 1+) (multiple-value-list (truncate (1- position)
>> >> 8))))
>> >
>> > Nobody spells out FUNCTION like this, use #'1+.  
>> 
>> I do.  I find it smoother than sharp and little bits in the eyes.
>
> Do you also spell out QUOTE?

Sometimes.  Not often, but it happens.

-- 
__Pascal Bourguignon__
From: William James
Subject: Re: please review my code
Date: 
Message-ID: <gnj1ga01v8n@enews2.newsguy.com>
Pascal J. Bourguignon wrote:

> Barry Margolin <······@alum.mit.edu> writes:
> >> (defun rank-file (position)
> >>   (mapcar (function 1+) (multiple-value-list (truncate (1-
> position) >> 8))))
> > 
> > Nobody spells out FUNCTION like this, use #'1+.  
> 
> I do.  I find it smoother than sharp and little bits in the eyes.

+1

And it's easier for a non-commune-lisper to understand.
From: Marco Antoniotti
Subject: Re: please review my code
Date: 
Message-ID: <f3e685aa-594a-4859-98d3-236b549723cf@x38g2000yqj.googlegroups.com>
On Feb 19, 8:24 am, "William James" <·········@yahoo.com> wrote:
> Pascal J. Bourguignon wrote:
> > Barry Margolin <······@alum.mit.edu> writes:
> > >> (defun rank-file (position)
> > >>   (mapcar (function 1+) (multiple-value-list (truncate (1-
> > position) >> 8))))
>
> > > Nobody spells out FUNCTION like this, use #'1+.  
>
> > I do.  I find it smoother than sharp and little bits in the eyes.
>
> +1
>
> And it's easier for a non-commune-lisper to understand.

As opposed to Ruby's syntax you mean?

Cheers
--
Marco
From: david
Subject: Re: please review my code
Date: 
Message-ID: <a6fb34cc-35de-4e6c-a3af-af179b9c5941@l1g2000yqj.googlegroups.com>
On Feb 18, 7:56 pm, Barry Margolin <······@alum.mit.edu> wrote:

> One thing that would help would be if you explained what your program is
> supposed to be doing.  I guess it's doing something with a checkerboard,
> because there are lots of 8x8 things, but other than that I can't figure
> out what all these things represent.

fen notation looks like this for starting chess position:
rnbqkbnr/pppppppp/8/8/8/8/PPPPPPPP/RNBQKBNR

or this for an endgame:
8/2B5/2N1K3/8/8/8/4k3/8

i was reading ansi common lisp and i thought of this when i saw
compress program.


>
> It also seems like you do lots of incrementing and subtracting, just to
> deal with the fact that your positions are 1-based.  If you used 0-based
> positions, wouldn't this all go away?
>

i will switch to zero based thinking forthwith

> Each time you call GET-POSITIONS it creates a new list of 4 random
> numbers.  So these four variables will not be the elements of one
> position list, they'll each be a different element of a different list.
> I doubt this is what you wanted.  What you probably want is something
> like this:
>
ha, i notice this bug before then i wrote it right back in.

> > (defparameter fenlist
> >   (make-list 8 :initial-element (make-list 8 :initial-element 0)))
>
> This will use the same list for all elements of fenlist, which is
> probably not what you want.
>

i think i understand. i was trying to make a template to fill in.


> Is there a reason why you're using a list of lists instead of an 8x8
> array?

i wanted to use paul grahams little compress program without having
to
make it work for arrays. that would be a good exercise though. also,
the why of anything i do at this point is i am a rank beginner.
i don't think i have ever actually finished a whole program. just
little exercises. though i did work through steve summit's excellent
c tutorials. and i took a pascal course in 1988 i think it was.
i am taking the learn programming in thirty years approach.
also, if i learn enough cl before i go back to finish my math bs
i may avoid having to learn c++.


> Wow, that's incresibly weird.  Don't you think the computer knows how to
> count to the place to fill in?
>
> (defun set-col (position piece)
>   (setf (nth (1- position) column) piece))
>
i almost got that to work. i am going to experiment with
changing the indexing. thanks for looking at my code.
From: Kenneth Tilton
Subject: Re: please review my code
Date: 
Message-ID: <499cfd55$0$5938$607ed4bc@cv.net>
david wrote:
> please for suggestions on how to learn programming, improve my code,
> have better cl style,
> and become a comp.lang.lisp hero. or just say my code sucks and/or i'm
> an idiot. i welcome
> all input. feelings are stupid.
> thanks, david
> 
> (defun random-position () (1+ (random 64)))   

Welcome to Lisp! You will fit right in. We have you pencilled in for 
electro-shock on Saturday, let us know if that does not work for you and 
we will reschedule.

> this looks much nicer in emacs

Good one. I could use some help around here with these deadweights.

kt
From: david
Subject: Re: please review my code
Date: 
Message-ID: <07c7dc44-f1c5-4207-bab4-33d2e02af5e0@w35g2000yqm.googlegroups.com>
thanks everyone for your help. the program is for
generating a forsyth edwards notation (fen) file
that contains a random knight bishop endgame.
i knew my string of setf was wrong but i wrote
that after repeated tries with nth led to failure.
i am using a list of lists instead of a 2d array
because i was going to use a compress function out
of "ansi common lisp" and i don't know how to make
that work with array. though i guess i could make
it work. also i will need to check for illegal
chess positions. that might be easier with array.
looking forward to the ect.

thanks, david
From: Pascal J. Bourguignon
Subject: Re: please review my code
Date: 
Message-ID: <7cd4de1q74.fsf@pbourguignon.anevia.com>
david <······@gmail.com> writes:

> thanks everyone for your help. the program is for
> generating a forsyth edwards notation (fen) file
> that contains a random knight bishop endgame.
> i knew my string of setf was wrong but i wrote
> that after repeated tries with nth led to failure.
> i am using a list of lists instead of a 2d array
> because i was going to use a compress function out
> of "ansi common lisp" and i don't know how to make
> that work with array. though i guess i could make
> it work. also i will need to check for illegal
> chess positions. that might be easier with array.
> looking forward to the ect.

The question would be, what does a chess player do with these FEN?

Does he take the notation and fill a chessboard with pieces?

Or does he think only in terms of FEN strings in his mind?

And vice versa, does a chess player take a chessboard filled with
pieces and convert it into a FEN only for the purpose of communicating
this FEN instead of gluing the pieces on the board and ups'ing it?


It should be obvious that you shouldn't consider FENs at all in your
program.  Only instead of using (print chessboard) at the end, you
could use (print-fen chessboard).

(defclass chessboard (...)
   (...))

(defmethod print-fen ((board chessboard) &optional (stream *standard-output*))
   (let ((sep ""))
     (row-by-row (r board)
        (princ sep stream)
        (setf sep "/")
        (loop
           :with e = 0
           :for c :from 0 :below (width board)
           :do (if (cell-empty-p (cell board r c))
                   (incf e)
                   (progn 
                       (when (plusp e)
                          (princ e stream)
                          (setf e 0))
                       (princ (cell-to-fen (cell board r c)) stream))))))
  (format stream " ~A ~A ~A ~A ~A" 
                 (color-to-fen (moves-next board))
                 (cast-availability-to-fen (available-casts board))
                 (cell-algebraic-coordinates (en-passant-target-cell board))
                 (half-move-clock board)
                 (full-move-number board)))
  

Now you only need to implement the missing methods on chessboard, and
the missing convertion functions.

For the rest of the program, you will add methods to the chessboard
objects to be able to manipulate it as a chessboard, with cells,
pieces, etc.

-- 
__Pascal Bourguignon__
From: david
Subject: Re: please review my code
Date: 
Message-ID: <bffab069-bfc5-4a4f-a5c6-9986c84cc9d9@i38g2000yqd.googlegroups.com>
On Feb 19, 8:01 am, ····@informatimago.com (Pascal J. Bourguignon)
wrote:
> david <······@gmail.com> writes:
> > thanks everyone for your help. the program is for
> > generating a forsyth edwards notation (fen) file
> > that contains a random knight bishop endgame.
> > i knew my string of setf was wrong but i wrote
> > that after repeated tries with nth led to failure.
> > i am using a list of lists instead of a 2d array
> > because i was going to use a compress function out
> > of "ansi common lisp" and i don't know how to make
> > that work with array. though i guess i could make
> > it work. also i will need to check for illegal
> > chess positions. that might be easier with array.
> > looking forward to the ect.
>
> The question would be, what does a chess player do with these FEN?
>
> Does he take the notation and fill a chessboard with pieces?
>
> Or does he think only in terms of FEN strings in his mind?
>
> And vice versa, does a chess player take a chessboard filled with
> pieces and convert it into a FEN only for the purpose of communicating
> this FEN instead of gluing the pieces on the board and ups'ing it?
>
> It should be obvious that you shouldn't consider FENs at all in your
> program.  Only instead of using (print chessboard) at the end, you
> could use (print-fen chessboard).
>

i'm not sure i understand you here. i will need time to consider.
let me outline my thinking.
(which i think is at a much lower level of abstraction here :)
i try to learn the bishop knight endgame. i set up position with
winboard and crafty and try to mate. i am always setting up positions.
one day i look at save file and look up fen on wikipedia.
i notice fen encoding is like run-length encoding which i read
in paul grahams book. i think this may be within my reach to program.
i think "this fen file is just a string which i can make with lisp."
i suffer bitter failure and ridicule at the hands of
comp.lang.lispers.
no, i am just trying to be funny.

> (defclass chessboard (...)
>    (...))
>
> (defmethod print-fen ((board chessboard) &optional (stream *standard-output*))
>    (let ((sep ""))
>      (row-by-row (r board)
>         (princ sep stream)
>         (setf sep "/")
>         (loop
>            :with e = 0
>            :for c :from 0 :below (width board)
>            :do (if (cell-empty-p (cell board r c))
>                    (incf e)
>                    (progn
>                        (when (plusp e)
>                           (princ e stream)
>                           (setf e 0))
>                        (princ (cell-to-fen (cell board r c)) stream))))))
>   (format stream " ~A ~A ~A ~A ~A"
>                  (color-to-fen (moves-next board))
>                  (cast-availability-to-fen (available-casts board))
>                  (cell-algebraic-coordinates (en-passant-target-cell board))
>                  (half-move-clock board)
>                  (full-move-number board)))
>
> Now you only need to implement the missing methods on chessboard, and
> the missing convertion functions.
>
> For the rest of the program, you will add methods to the chessboard
> objects to be able to manipulate it as a chessboard, with cells,
> pieces, etc.
>
> --
> __Pascal Bourguignon__

that is beautiful. i will study that for a few days and get back to
you.
From: Pascal J. Bourguignon
Subject: Re: please review my code
Date: 
Message-ID: <7cr61uz9k6.fsf@pbourguignon.anevia.com>
david <······@gmail.com> writes:

> On Feb 19, 8:01 am, ····@informatimago.com (Pascal J. Bourguignon)
> wrote:
>> david <······@gmail.com> writes:
>> > thanks everyone for your help. the program is for
>> > generating a forsyth edwards notation (fen) file
>> > that contains a random knight bishop endgame.
>> > i knew my string of setf was wrong but i wrote
>> > that after repeated tries with nth led to failure.
>> > i am using a list of lists instead of a 2d array
>> > because i was going to use a compress function out
>> > of "ansi common lisp" and i don't know how to make
>> > that work with array. though i guess i could make
>> > it work. also i will need to check for illegal
>> > chess positions. that might be easier with array.
>> > looking forward to the ect.
>>
>> The question would be, what does a chess player do with these FEN?
>>
>> Does he take the notation and fill a chessboard with pieces?
>>
>> Or does he think only in terms of FEN strings in his mind?
>>
>> And vice versa, does a chess player take a chessboard filled with
>> pieces and convert it into a FEN only for the purpose of communicating
>> this FEN instead of gluing the pieces on the board and ups'ing it?
>>
>> It should be obvious that you shouldn't consider FENs at all in your
>> program.  Only instead of using (print chessboard) at the end, you
>> could use (print-fen chessboard).
>>
>
> i'm not sure i understand you here. i will need time to consider.
> let me outline my thinking.
> (which i think is at a much lower level of abstraction here :)
> i try to learn the bishop knight endgame. i set up position with
> winboard and crafty and try to mate. i am always setting up positions.
> one day i look at save file and look up fen on wikipedia.
> i notice fen encoding is like run-length encoding which i read
> in paul grahams book. i think this may be within my reach to program.
> i think "this fen file is just a string which i can make with lisp."

Yes, that's exactly this.

Till now you've showed things (such as random-position) that are
unrelated to FEN.  You should write them only in function of your
internal data structures, the data structures you use to "try to learn
the bishop knight endgame, set up position with winboard and crafty
and try to mate, always setting up positions".

When you're done with that, you can take these internal data
structures, and conver them to a FEN string for output.  (And you may
write the reverse, parsing a FEN string and produce an internal data
structure proper to further play and try to mate).


> that is beautiful. i will study that for a few days and get back to
> you.

Yes.  Fill the blanks, implement the missing methods.

-- 
__Pascal Bourguignon__
From: Stanisław Halik
Subject: Re: please review my code
Date: 
Message-ID: <gnie8q$11ra$1@opal.icpnet.pl>
thus spoke david <······@gmail.com>:

> (defun set-col (position piece)
>  (case position
>    ((1)(setf (first column) piece))
>    ((2)(setf (second column) piece))
>    ((3)(setf (third column) piece))
>    ((4)(setf (fourth column) piece))
>    ((5)(setf (fifth column) piece))
>    ((6)(setf (sixth column) piece))
>    ((7)(setf (seventh column) piece))
>    ((8)(setf (eighth column) piece))))

Ick.

(defun set-col (position piece)
  (check-type position (integer 1 8))
  (rplaca (nthcdr position) piece))

> (defun set-row (row)
>           (case row
>             ((1)(setf (first fenlist) column))
>             ((2)(setf (second fenlist) column))
>             ((3)(setf (third fenlist) column))
>             ((4)(setf (fourth fenlist) column))
>             ((5)(setf (fifth fenlist) column))
>             ((6)(setf (sixth fenlist) column))
>             ((7)(setf (seventh fenlist) column))
>             ((8)(setf (eighth fenlist) column))))

Same here.
From: Thomas A. Russ
Subject: Re: please review my code
Date: 
Message-ID: <ymi1vtus0qj.fsf@blackcat.isi.edu>
Stanis�aw Halik <·······@test123.ltd.pl> writes:

> thus spoke david <······@gmail.com>:
> 
> > (defun set-col (position piece)
> >  (case position
> >    ((1)(setf (first column) piece))
> >    ((2)(setf (second column) piece))
> >    ((3)(setf (third column) piece))
> >    ((4)(setf (fourth column) piece))
> >    ((5)(setf (fifth column) piece))
> >    ((6)(setf (sixth column) piece))
> >    ((7)(setf (seventh column) piece))
> >    ((8)(setf (eighth column) piece))))
> 
> Ick.
> 
> (defun set-col (position piece)
>   (check-type position (integer 1 8))
>   (rplaca (nthcdr position) piece))

Why not just:
  (setf (nth position column) piece)
?


To the OP:  If you really want random access, though, an array would be
a better choice than nested lists.


-- 
Thomas A. Russ,  USC/Information Sciences Institute
From: Pascal J. Bourguignon
Subject: Re: please review my code
Date: 
Message-ID: <87wsbnjifx.fsf@galatea.local>
david <······@gmail.com> writes:

> please for suggestions on how to learn programming, improve my code,
> have better cl style,
> and become a comp.lang.lisp hero. or just say my code sucks and/or i'm
> an idiot. i welcome
> all input. feelings are stupid.

Ok, you asked for it.

> (defparameter wk (rank-file (first (get-positions))))
> (defparameter wb (rank-file (second (get-positions))))
> (defparameter wn (rank-file (third (get-positions))))
> (defparameter bk (rank-file (fourth (get-positions))))

This is silly.  GET-POSITIONS is not a function, because RANDOM is not
a function (mathematically speaking).  By calling GET-POSITIONS
several times, you lose the postcondition that all the returned
positions are different, and you get a probability of more than 1/10
to get two same positions.


Naming special variables without respecting the earmuff convention is
quite dangerous.  This can break code using lexical variables of same
name.

With an editor like emacs at the REPL, there's no reason why not using
lexical variables, even interactively.

   (destructuring-bind (wk wb wn bk) (mapcar (function rank-file) (get-positions))
     (do-something-with wk wb wn bk))

is shorter and more correct than your bunch of defparameters.



> (defparameter fenlist
>   (make-list 8 :initial-element (make-list 8 :initial-element 0)))
>
> (defparameter column (make-list 8 :initial-element 0))

Using global variables is wrong anyways.  It will bite you.  Just say no.


> (defun set-col (position piece)
>   (case position
>     ((1)(setf (first column) piece))
>     ((2)(setf (second column) piece))
>     ((3)(setf (third column) piece))
>     ((4)(setf (fourth column) piece))
>     ((5)(setf (fifth column) piece))
>     ((6)(setf (sixth column) piece))
>     ((7)(setf (seventh column) piece))
>     ((8)(setf (eighth column) piece))))


(defun set-col (column position piece)
  (setf (aref column position) pieces)) ;; did we need a function to do that???


(let ((column (make-array 8 :initial-element nil))) ; Is 0 a piece???
   (set-col column 2 'wk)
   column)



> (defun set-row (row)
> 	   (case row
> 	     ((1)(setf (first fenlist) column))
> 	     ((2)(setf (second fenlist) column))
> 	     ((3)(setf (third fenlist) column))
> 	     ((4)(setf (fourth fenlist) column))
> 	     ((5)(setf (fifth fenlist) column))
> 	     ((6)(setf (sixth fenlist) column))
> 	     ((7)(setf (seventh fenlist) column))
> 	     ((8)(setf (eighth fenlist) column))))

(defun set-row (fenlist row column)
  (setf (aref fenlist row) column))  ;; really??


> (defun make-fen (row col piece)
> 	   (set-col col piece)
> 	   (set-row row))

Why don't you use a 2D array?

(defun make-fen (row col piece)
   (let ((fen (make-array '(8 8) :initial-element '|.|)))
     (setf (aref fen row col) piece)
     fen))

(make-fen 1 2 'wki)
-->
#2A((|.| |.| |.| |.| |.| |.| |.| |.|)
    (|.| |.| WKI |.| |.| |.| |.| |.|)
    (|.| |.| |.| |.| |.| |.| |.| |.|)
    (|.| |.| |.| |.| |.| |.| |.| |.|)
    (|.| |.| |.| |.| |.| |.| |.| |.|)
    (|.| |.| |.| |.| |.| |.| |.| |.|)
    (|.| |.| |.| |.| |.| |.| |.| |.|)
    (|.| |.| |.| |.| |.| |.| |.| |.|))


-- 
__Pascal Bourguignon__
From: Pascal J. Bourguignon
Subject: Re: please review my code
Date: 
Message-ID: <87ljs3ji5h.fsf@galatea.local>
···@informatimago.com (Pascal J. Bourguignon) writes:

> david <······@gmail.com> writes:
>> (defun set-col (position piece)
>>   (case position
>>     ((1)(setf (first column) piece))
>>     ((2)(setf (second column) piece))
>>     ((3)(setf (third column) piece))
>>     ((4)(setf (fourth column) piece))
>>     ((5)(setf (fifth column) piece))
>>     ((6)(setf (sixth column) piece))
>>     ((7)(setf (seventh column) piece))
>>     ((8)(setf (eighth column) piece))))
>
>
> (defun set-col (column position piece)
>   (setf (aref column position) pieces)) ;; did we need a function to do that???

Well obviously this is wrong unless you use 0-based indices, as we
already all mentionned you should.

-- 
__Pascal Bourguignon__
From: david
Subject: Re: please review my code
Date: 
Message-ID: <c76180db-b099-42a5-bddc-185dbdd225b9@d32g2000yqe.googlegroups.com>
On Feb 18, 7:58 pm, ····@informatimago.com (Pascal J. Bourguignon)
wrote
> Ok, you asked for it.


thanks. i will need some time to consider all this. back to my
textbooks :)
also, my google doesnt have "earmuff convention"
From: John Thingstad
Subject: Re: please review my code
Date: 
Message-ID: <op.uplk6optut4oq5@pandora.alfanett.no>
P� Thu, 19 Feb 2009 12:55:32 +0100, skrev david <······@gmail.com>:

> On Feb 18, 7:58 pm, ····@informatimago.com (Pascal J. Bourguignon)
> wrote
>> Ok, you asked for it.
>
>
> thanks. i will need some time to consider all this. back to my
> textbooks :)
> also, my google doesnt have "earmuff convention"

a variable of this style *name*.
(It sounds wierd to me too.)

--------------
John Thingstad
From: david
Subject: Re: please review my code
Date: 
Message-ID: <07b751f0-26d4-445b-a17e-7bb61b955bf8@o11g2000yql.googlegroups.com>
On Feb 19, 6:05 am, "John Thingstad" <·······@online.no> wrote:
> På Thu, 19 Feb 2009 12:55:32 +0100, skrev david <······@gmail.com>:
>
> > On Feb 18, 7:58 pm, ····@informatimago.com (Pascal J. Bourguignon)
> > wrote
> >> Ok, you asked for it.
>
> > thanks. i will need some time to consider all this. back to my
> > textbooks :)
> > also, my google doesnt have "earmuff convention"
>
> a variable of this style *name*.
> (It sounds wierd to me too.)
>
> --------------
> John Thingstad

lol