Re: no set-car! in clojure

2015-08-06 Thread Herwig Hochleitner
You could define your own cons type, like Bodil Stokke did for her microkanren https://github.com/bodil/microkanrens/blob/77dbdc34cde580e26765138102cbdabbfad85b9d/mk.clj#L13 If you mark its fields with ^:volatile-mutable, you can call (set! (.-a lst) new-car) on a cons instance. cheers -- You re

Re: no set-car! in clojure

2015-08-06 Thread Francis Avila
There is no equivalent to set-car!, because conses are not mutable. Only vars, refs, atoms, and agents are mutable, and they are simply containers for immutable values. You could put a cons inside an atom and put a new transformed list into the atom. (Note even among schemes set-car! is highly

Re: no set-car! in clojure

2015-08-06 Thread James Reeves
As with all Clojure data structures, lists in Clojure are immutable, so they cannot be modified in place. Also, defs in Clojure are always global to the current namespace, no matter where they are. For this reason, it's generally not a good idea to nest defns. You may want to refer to how other p