2

Why is '(1 2 3) written instead of (1 2 3) ?

> (list 1 2 3)
'(1 2 3)
citykid
  • 9,916
  • 10
  • 55
  • 91

1 Answers1

5

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.

Ryan Culpepper
  • 10,495
  • 4
  • 31
  • 30