PDA

View Full Version : CLisp won't output


SolarBear
07-01-2004, 12:08 PM
This may be more of a problem with clisp thant with the language itself, but here goes.

I have the following dumb script :
#!/usr/bin/clisp
(defun isinlist (lst elm)
(if (eql (car lst) elm)
t
(isinlist (cdr lst) elm)))
(isinlist '(1 2 3) 3)
which is obviously used to look if a element is part of a list or not. When I put these 2 instructions in the clisp interpreter, it works fine. However, if I use it as a script and try to execute it, I get no output. The function should return T since 3 is part of the list.

Is there anything I'm missing ?

GnuVince
07-01-2004, 12:28 PM
You don't have any output statement. CHange your last line to:


(format t "~A~%" (isinlist '(1 2 3) 3))


That oughta work.

SolarBear
07-01-2004, 04:37 PM
Ah thanks, don't know why I didn't think of that.

While we're at it, a related question : why do we pass "true" as first argument to format ? I have yet to see a non-true value there.

GnuVince
07-01-2004, 06:14 PM
When you pass true, the output will go to *standard-output*. If you pass a stream argument, the output will go there. If you pass nil, there will be no output. You typically use nil to set a string variable:

(setf my-string (format nil "~A~A" 'Hello 'World))


Hope that helps.

SolarBear
07-01-2004, 08:14 PM
Indeed it helps, that makes sense.

Gee... I borrowed that book on Lisp by sheer curiosity ("AHAH ! Lisp !" I thought). Now I'm reading it cover to cover. Still need to do anything "useful" with it, though.