The lisp interpreter works in a Read-eval-print loop or REPL for short. To understand this we can imagine that the lisp interpreter reads the first word till whitespace, interprets it, reads more words if required , interprets them and prints the output.
It can also be understood as (function_name argument1 argument2 .....) where each argument can be a function in itself. So to print a string all is required is the string in double quotes.
Here + is the operator followed two arguments, 2 and 3. So the lisp interpreter knows after reading the first word that it should expect numbers and the user expects to add all these numbers. So if we specify 10 numbers then we can get their sum in one line.
and divide...
It can also be understood as (function_name argument1 argument2 .....) where each argument can be a function in itself. So to print a string all is required is the string in double quotes.
CL-USER> "hello, world"
"hello, world"
Adding two numbers becomes more complicated. But it is easier if you remember that the function/operator comes first followed by the arguments. So,CL-USER> (+ 2 3)
5Here + is the operator followed two arguments, 2 and 3. So the lisp interpreter knows after reading the first word that it should expect numbers and the user expects to add all these numbers. So if we specify 10 numbers then we can get their sum in one line.
CL-USER> (+ 1 2 3 4 5 6 7 8 9 10)
55
But what if we do this with subtract?
CL-USER> (- 3 2 1)
0and divide...
CL-USER> (/ 1 2 4)
1/8
More functions tomorrow...