Key order of literal maps

2011-05-03 Thread David Jagoe
Hey everyone, I'm busy implementing a macro whose usage looks like this: (defentity Person {:name {:type String :validator name-validator} :id-number {:type String :validator id-number-validator} :height{:type Float :default 0.0} :weight{:type Float :default 0.0}

Re: Key order of literal maps

2011-05-03 Thread Armando Blancas
Keys from literal maps aren't sorted; you need a sorted map. user= (keys {:z 1 :f 2 :a 0}) (:z :a :f) user= (keys (sorted-map :z 1 :f 2 :a 0)) (:a :f :z) On May 3, 4:08 am, David Jagoe davidja...@gmail.com wrote: Hey everyone, I'm busy implementing a macro whose usage looks like this:

Re: Key order of literal maps

2011-05-03 Thread Steve Miner
On May 3, 2011, at 7:08 AM, David Jagoe wrote: Can I rely on (keys some-literal-map) always returning the keys in the order they were defined in the literal map? In general, the key order is not guaranteed, but an array-map will maintain the insertion order of the keys. Use the array-map

Re: Key order of literal maps

2011-05-03 Thread David Jagoe
Thanks for the responses. On 3 May 2011 17:39, Steve Miner stevemi...@gmail.com wrote: On May 3, 2011, at 7:08 AM, David Jagoe wrote: For your specific purpose, I would be careful about using a map as an entity specification. If the order is significant, a vector of field specifiers would