From: Bjorn Goldis
Subject: adding letters to list front
Date: 
Message-ID: <fzbL2.5231$5n6.30663868@news2.jacksonville.net>
have set a list to a name:

(defun stack-init (name)
     ( set name '(()) ) ) ;; want to initialize to empty list.

want to append letter to list named name:

(defun pushS (name elem)
        ( cons elem name) )  ;;

this does attach new letter but replaces former one,
behaving like setf instead of cons.
also, get (A NIL) form instead of just (A) with return.

every pushS ought to add one new letter, showing
the addition only without NIL in there.

any suggestions?

clue-less in lisp-ville
From: R. Matthew Emerson
Subject: Re: adding letters to list front
Date: 
Message-ID: <7djqor$f8b$1@news-2.news.gte.net>
"Bjorn Goldis" <·······@MediaOne.Net> writes:
> 
> have set a list to a name:
> 
> (defun stack-init (name)
>      ( set name '(()) ) ) ;; want to initialize to empty list.

the empty list is not '(()).  you can write the empty list
as just '().  '(()) is the list containing the empty list.

> want to append letter to list named name:
> 
> (defun pushS (name elem)
>         ( cons elem name) )  ;;
> 
> this does attach new letter but replaces former one,
> behaving like setf instead of cons.
> also, get (A NIL) form instead of just (A) with return.
>
> every pushS ought to add one new letter, showing
> the addition only without NIL in there.

that NIL is in there because you put it there in stack-init.
note that in CL, '(), (), NIL, and 'NIL are all the same.
Which version to use is based on circumstance:  if you wish
to emphasize that you're using an empty list, use '(), for boolean,
false, use NIL.  see CLTL2 section 1.2.2 for an explaination,
or read the glossary entries for NIL, the empty list, and () in
the hyperspec.

you would probably benefit from reading the Little Lisper (now
called the Little Schemer).

-matt