4 ms·
What is the name for illustrating the point with deliberately unrelated example? His clojure code fails because he did not swap nil? for empty? (and he even sta
by dunkelheit 11y ago
What is the name for illustrating the point with deliberately unrelated example? His clojure code fails because he did not swap nil? for empty? (and he even states this in the article) but he then uses it to illustrate the absence of TCO in clojure.
- TazeTSchnitzel 11y agonil? is a pretty big thing. Is Clojure even a Lisp if nil is not the empty list? Edit: Jesus Christ, Clojure doesn't even have conses. Why the hell do people call this a "Lisp"? > (= () nil) false > (('a . 'b) . ('a . 'b)) java.lang.RuntimeException: Unable to resolve symbol: . in this context > (cons 'a 'b) java.lang.IllegalArgumentException: Don't know how to create ISeq from: clojure.lang.Symbol
- dewitt 11y agoSure, it does have cons, but your second argument wasn't a sequence. Try: > (cons 'a ['b]) (a b) > (doc cons) ------------------------- clojure.core/cons ([x seq]) Returns a new seq where x is the first element and seq is the rest.
- tokenrove 11y agoIn other Lisps, a cons can be an arbitrary pair.
- TazeTSchnitzel 11y agoThat's not a cons, that's a linked list. As tokenrove mentions, a cons in a Lisp is just a tuple (`cons` is the name of the type and the function constructing it). It can contain any two values.