Clojure equivalent for cons/car/cdr here

(cons 1 2) doesn’t work in Clojure; you get:

Don't know how to create ISeq from: java.lang.Integer
[Thrown class java.lang.IllegalArgumentException]

In Scheme, “a chain of pairs not ending in the empty list is called an improper list. Note that an improper list is not a list. ”

(cons 'a 3) => (a . 3)

To do the exercises in Clojure, one can use

(def x (list 1 2))
(first x)
(last x)


  • Web page addresses and e-mail addresses turn into links automatically.
  • Allowed HTML tags: <a> <em> <strong> <cite> <code> <pre> <hr> <ul> <ol> <li> <dl> <dt> <dd> <img>
  • Lines and paragraphs break automatically.
  • Adds typographic refinements.

More information about formatting options