4 ms·
Can't it? This seems to work just fine: (cons :a (cons '[x] (cons {:foo :bar} #{:x :y}))) and cljs.user=> (rest (cons :a (cons '[x] (cons {:foo :bar} #{:x :y}))
by phyrex 10y ago
Can't it? This seems to work just fine:
(cons :a (cons '[x] (cons {:foo :bar} #{:x :y})))
and
cljs.user=> (rest (cons :a (cons '[x] (cons {:foo :bar} #{:x :y}))))
;=> ([x] {:foo :bar} :x :y)
Maybe I don't understand what you mean. I also don't see why a uniform cell structure would be preferable?
- qwertyuiop924 10y agoThe result you got isn't actually what you'd get with proper cons cells. With real conses, you wouldn't get a list, you'd get an improper list, or a pair: i.e: Scheme: (define x (cons 'a (cons 'b '()))) ;> (a b) (define y (cons 'a 'b)) ;> (a . b) (cdr x) ;> (b) (cdr y) ;> b (eq x y) ;> #f If clojure doesn't behave like that, that it's not using real conses. As for why a uniform cell structure is preferable, it's a preference thing, but I feel it makes dealing with lists and other cons-based structure (mostly lists, but you get the occaisional alist or plist or tree in there too) much nicer.