News for hackers. Stuff that matters.
Re:Learning Lisp The Bump Free Way by chimeracoder on Wednesday April 24, 2013 @08:23PM (#5604945)
Wait, this one is news to me. How does Clojure break this? It still supports car/cdr, if I recall correctly, right?
Re:Learning Lisp The Bump Free Way by Xurinos on Wednesday April 24, 2013 @11:59PM (#5605636)
The closest Clojure has to car/cdr is first/rest. It supports "cons" but only for creating sequences. Traditional Lisp car/cdr is one-location/other-location, and its cons puts together pairs of data. Often this is used for constructing sequences, but it is also often used for trees.

Clojure:

    user=> (cons 3 4)
    IllegalArgumentException Don't know how to create ISeq from: java.lang.Long  clojure.lang.RT.seqFrom (RT.java:494)

    user=> (cons 3 '(4))
    (3 4)

Common Lisp:

    CL-USER(1): (cons 3 4)

    (3 . 4)
    CL-USER(2): (cons 3 '(4))

    (3 4)
    CL-USER(3):
Re:Learning Lisp The Bump Free Way by kyllo on Thursday April 25, 2013 @02:22AM (#5605956)
Yeah those error messages completely baffled me for the first few hours I spent in the Clojure REPL. It was strange enough to not have car/cdr and cons for working with tuples, but then I wrote a simple recursive algorithm and got a java.lang.StackOverflowError. I now understand why and the alternative idioms that Clojure provides, but at the time it was a WTF moment.
Re:Learning Lisp The Bump Free Way by omaranto on Thursday April 25, 2013 @12:02AM (#5605647)
they are called first and rest in clojure, not car and CDR.