sbcl newbie question

Whatever is on your mind, whether Lisp related or not.

sbcl newbie question

Postby joybee » Wed Jan 07, 2009 2:02 pm

I just start to learn Lisp. And my question is

When I enter (princ "Hello"), why there are two lines of Hello printed out, one without quote, one with double quote. Same happened to print or write-line. But when I type (format t "Hello"), only one line Hello came out with Nil.

Can anyone explain why it works this way? Thanks!
joybee
 
Posts: 21
Joined: Wed Jan 07, 2009 1:49 pm

Re: sbcl newbie question

Postby dmitry_vk » Wed Jan 07, 2009 3:14 pm

joybee wrote:I just start to learn Lisp. And my question is

When I enter (princ "Hello"), why there are two lines of Hello printed out, one without quote, one with double quote. Same happened to print or write-line. But when I type (format t "Hello"), only one line Hello came out with Nil.

Can anyone explain why it works this way? Thanks!

You enter the expression into the REPL (Read-Eval-Print Loop), which evaluates the expression and prints the result. print and princ return their argument. So, one line is printed from print/princ themselves, and the other is from the REPL. (format t ...) returns NIL, so NIL is printed.
dmitry_vk
 
Posts: 96
Joined: Sat Jun 28, 2008 8:01 am
Location: Russia, Kazan

Re: sbcl newbie question

Postby joybee » Thu Jan 08, 2009 8:05 am

Thanks for your help, Dmitry!

I am so glad that I found this forum. Thanks for the site, Dave!
joybee
 
Posts: 21
Joined: Wed Jan 07, 2009 1:49 pm


Return to The Lounge

Who is online

Users browsing this forum: No registered users and 2 guests