Why does evaluating (list + 1 2)
in Common Lisp (CCL REPL) returns ('(+ 1 2) 1 2)
?
More: OK, I see that +
actually evaluates to the last REPL result, but I still have a question: Is this a standard CL REPL thing, to have +
equal to the last result, or is it Clozure specific?
To compare two numbers for numerical equality and type equality, use eql. The arguments may be any non-complex numbers. max returns the argument that is greatest (closest to positive infinity). min returns the argument that is least (closest to negative infinity).
One of us learned LISP in the old days, so occasionally we'll use car or cdr instead of first or rest.) Rest takes a list as an argument and returns the list, minus its first element. You can figure out the rest, like how to get at the third and fourth elements of the list using first and rest.
The apostrophe or single-quote character marks an expression or symbol as a literal expression, to be taken at 'face-value' and not to be evaluated by the AutoLISP interpreter.
These types include integer, float, cons, symbol, string, vector, hash-table, subr, byte-code function, and record, plus several special types, such as buffer, that are related to editing.
You will find that, in the REPL, the variable *
holds the last result, and +
holds the last evaluated form.
For example:
> (+ 1 2)
=> 3
> +
=> (+ 1 2)
> (+ 2 3)
=> 5
> *
=> 5
Yes, these are standard, and in the HyperSpec.
If you wish to create a list containing the symbol +
, rather than its value, you will need to quote it, as such: '+
, or (quote +)
.
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