Re: Newbie lisp problem: string to list of strings separated by space



Yossarian <yossarian@xxxxxxxxxxx> writes:
Use a local variable! Use LET

Indeed, the idea was to use a local variable ...
Now, if I replace "setq" with "let", then I receive the following error.
Are there extra requirements for using "let"? What is wrong now?

(defun parse(a)
(let pos (or (position #\space a) -1) )
(cond ((= pos -1) (list a))
((> pos -1) (append
(parse (subseq a 0 pos))
(parse (subseq a (+ pos 1) (length
a)))))))
;;; Warning: Function not defined: PARSE
;;; An error occurred in function #< COMPILED-FUNCTION: #xD0F828 >:
;;; Error: The variable A is unbound

It might be a good idea to read some tutorial and some reference
manual. You wouldn't want to be taken for a Mondoshawan, would you?


Zorg: I hate warriors, too narrow-minded. I'll tell you what I do
like: a killer, a died-in-the-wood killer. Cold blooded
methodical. Now a real killer when he picked up the ZF-1,
would have immediately asked about the little red button on
the bottom of the gun.

Aknot: [Scene shifts to Aknot, who is staring in confusion at the
little red button. He shrugs and pushes it]

Zorg: [Casually smokes a cigarette as the room with the Mangalores
blows up] Bring me the priest.


http://www.imdb.com/title/tt0119116/quotes
http://www.cliki.net/Education
http://www.lispworks.com/documentation/HyperSpec/Front/Contents.htm
http://www.lispworks.com/documentation/HyperSpec/Body/s_let_l.htm

--
__Pascal Bourguignon__ http://www.informatimago.com/

CAUTION: The mass of this product contains the energy equivalent of
85 million tons of TNT per net ounce of weight.
.


Quantcast