Why is '(1 2 3) written instead of (1 2 3) ?
> (list 1 2 3)
'(1 2 3)
Why is '(1 2 3) written instead of (1 2 3) ?
> (list 1 2 3)
'(1 2 3)
Racket's default printer prints a value as an expression that would evaluate to an equivalent value (when possible). It uses quote
(abbreviated '
) when it can; if a value contains an unquotable data structure, it uses constructor functions instead. For example:
> (list 1 2 3)
'(1 2 3)
> (list 1 2 (set 3)) ;; sets are not quotable
(list 1 2 (set 3))
Most Lisps and Schemes print values using the write
function instead. You can change Racket's printer to write
mode using the print-as-expression
parameter, like this:
> (print-as-expression #f)
> (list 1 2 3)
(1 2 3)
See the docs on the Racket printer for more information.
© 2022 - 2024 — McMap. All rights reserved.
(list 1 2 3)
should return(1 2 3)
. Printing'(1 2 3)
is incorrect. – Engraving