I just started using lisp today (coming from C-esque languages), so
please be gentle ;)
This is from the CLISP 2.33.1 in iteractive mode:
[3]> (setq inputTemp 5)
5
- [4]> (setq input '(1 2 3))
(1 2 3)
- [5]> (append '(inputTemp) input)
(INPUTTEMP 1 2 3)
From documents I know append joins two lists. Append also works fine
if I use a constant list in place of the inputTemp atom (that's a
single value in lisp terms I think, right?). The INPUTTEMP in caps
also shows up if I call the print function. I'm sure I'm doing
something obviously wrong, but I can't seem to spot it. If I combine
push and reverse I can do the task just fine, but append appears to be
the correct function for the job.
From: Svein Ove Aas
Subject: Re: Novice: problem with atoms showing up in caps with append
Date:
Message-ID: <cp1luu$snj$1@services.kq.no>
Brian Peyton wrote:
> I just started using lisp today (coming from C-esque languages), so
> please be gentle ;)
>
>
> This is from the CLISP 2.33.1 in iteractive mode:
> [3]> (setq inputTemp 5)
> 5
> - [4]> (setq input '(1 2 3))
> (1 2 3)
> - [5]> (append '(inputTemp) input)
> (INPUTTEMP 1 2 3)
>
> From documents I know append joins two lists. Append also works fine
> if I use a constant list in place of the inputTemp atom (that's a
> single value in lisp terms I think, right?). The INPUTTEMP in caps
> also shows up if I call the print function. I'm sure I'm doing
> something obviously wrong, but I can't seem to spot it. If I combine
> push and reverse I can do the task just fine, but append appears to be
> the correct function for the job.
You're not doing anything wrong; the Lisp reader upcases all symbols (such
as inputtemp) by default. I suggest you repent quickly, before the ravening
Lispnik hordes overtake you. You never know what they might do.
More seriously, Lisp allows a number of other characters in symbol names, so
we don't *need* uppercase to separate words, and it does cut down on
misspellings when SYstem.out.println is considered correct, although you'd
never see a function name that ugly in Lisp.
I suggest you use input-temp instead. There *is* a way to do what you want,
but I'm not going to tell you before you've tried it this way; besides,
someone else will probably tell you anyway.
············@gmail.com (Brian Peyton) writes:
> I just started using lisp today (coming from C-esque languages), so
> please be gentle ;)
>
>
> This is from the CLISP 2.33.1 in iteractive mode:
> [3]> (setq inputTemp 5)
> 5
> - [4]> (setq input '(1 2 3))
> (1 2 3)
> - [5]> (append '(inputTemp) input)
> (INPUTTEMP 1 2 3)
>
> From documents I know append joins two lists. Append also works fine
> if I use a constant list in place of the inputTemp atom (that's a
> single value in lisp terms I think, right?). The INPUTTEMP in caps
> also shows up if I call the print function. I'm sure I'm doing
> something obviously wrong, but I can't seem to spot it. If I combine
> push and reverse I can do the task just fine, but append appears to be
> the correct function for the job.
Read the chapter 2 Syntax and the chapter 23 Reader of the Common-Lisp
HyperSpec CLHS www.lispworks.com/reference/HyperSpec/Front/Contents.htm
(When you'll have read all chapters from 1 to 26, you won't be a
newbie anymore :-)
--
__Pascal Bourguignon__ http://www.informatimago.com/
The world will now reboot; don't bother saving your artefacts.