Re: How do Clojure functions update def variables

2011-06-30 Thread Mark Rathwell
True, I did not mean to imply that they should be used in situations such as this, only that they are data structures in the language that are mutable, and have situations where they may be useful. - Mark On Thu, Jun 30, 2011 at 12:17 PM, Phil Hagelberg wrote: > Mark Rathwell writes: > > > Cl

Re: How do Clojure functions update def variables

2011-06-30 Thread Phil Hagelberg
Mark Rathwell writes: > Clojure data structures are immutable by default > (see http://clojure.org/functional_programming). > > For mutability, see the following: > > [...] > > http://clojure.org/transients It's a common misconception that transients are meant to be used for mutable data, but th

Re: How do Clojure functions update def variables

2011-06-30 Thread octopusgrabbus
You're correct. They both do the same thing. Both do not update mtr- map. Clearly I need to assign a local variable in a let statement. (mtr-map passed as parameter version) (def mtr-seq ["a" 1 "b" 2 "c" 3 "d" 4]) (defn map-mtr [read-map premid reading] (conj read-map {premid re

Re: How do Clojure functions update def variables

2011-06-30 Thread Mark Rathwell
It shouldn't. I can't duplicate what I think you are saying. Would you be able to you print the code you entered in the repl that produced these results? On Thu, Jun 30, 2011 at 12:02 PM, octopusgrabbus wrote: > Thanks you for answering. > > I should rephrase the question, and I'll go look at

Re: How do Clojure functions update def variables

2011-06-30 Thread octopusgrabbus
Thanks you for answering. I should rephrase the question, and I'll go look at the links you posted. I'm wondering why conj worked in the first of the function that operated on the mtr-map defined by def, and not in the version where mtr-map was passed in as the first parameter. On Jun 30, 11:48 

Re: How do Clojure functions update def variables

2011-06-30 Thread Mark Rathwell
Clojure data structures are immutable by default (see http://clojure.org/functional_programming). For mutability, see the following: http://clojure.org/vars http://clojure.org/atoms http://clojure.org/refs http://clojure.org/agents http://clojure.org/transients On

How do Clojure functions update def variables

2011-06-30 Thread octopusgrabbus
Given this empty map, (def mtr-map {}) this sequence, (def mtr-seq ["a" 1 "b" 2 "c" 3 "d" 4]) this function, (defn map-mtr [read-map premid reading] (conj read-map {premid reading})) and this call (map-mtr mtr-map (first mtr-seq) (first (rest mtr-seq))) mtr-map won't update, but red