I'm very new to Lisp and am trying to write a program that simply asks a user to enter 3 numbers and then sums them and prints the output.
I've read that you can you a function like:
(defvar a)
(setq a (read))
To set a variable in Lisp, but when I try to compile my code using LispWorks I get the following error:
End of file while reading stream #<Concatenated Stream, Streams = ()>
I feel like this should be relatively simple and have no idea where I'm going wrong.
Print a carriage return. This function prints a new line to the command prompt area, and returns nil. Example. Code.
1.9. 2 Using setq This special form is just like set except that the first argument is quoted automatically, so you don't need to type the quote mark yourself. Also, as an added convenience, setq permits you to set several different variables to different values, all in one expression.
Unfortunately, Lisp has many flavors which means the following implementation of Hello World will likely only be applicable to handful of those flavors: (format t "Hello, World!") (format t "Hello, World!")
Use the TERPRI function (the name stands for "terminate printing", as it's intended to be used to terminate a line of output). You could also use FRESH-LINE . This prints a newline unless you're already at the start of a line.
I've not worked with LispWorks, so it's only a guess.
When compiler traverses your code it gets to the line (setq a (read))
, it tries to read input, but there is no input stream while compiling, thus you get an error.
Write a function:
(defvar a)
(defun my-function ()
(setq a (read))
It should work.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With