3 ms·
> '(3 . 4) is a valid expression in Clojure True, just not a cons cell. It's a persistentList with three elements: 3, ., and 4. Clojure has a higher-level bas
by lispm 6y ago
> '(3 . 4) is a valid expression in Clojure
True, just not a cons cell. It's a persistentList with three elements: 3, ., and 4.
Clojure has a higher-level basic data-structure than the usual Lisp. In those Lisps cons cells are are nothing more than a two-element record, a few basic operations (CONS, CONSP, CAR, CDR, RPLACA, RPLACD) and a special data syntax for them: ( a . b ). In a typical Lisp, the dot is not a list element, but divides the car from the cdr. Additional there is simpler notation for (a . (b . nil)) in the form of (a b) .
- klibertp 6y agoI stand corrected. I used Clojure briefly a few years ago, so I don't remember much. I even ran a REPL and checked if it's a valid syntax, but it didn't occur to me to check its type. Sorry!
- disgruntledphd2 6y agoR also has cons cells, called pairlists. They are generally only used for function arguments though.