On Saturday, November 2, 2013 4:56:13 PM UTC-5, Jozef Wagner wrote:
>
> Problem is, when your proposed dissoc removes value from a vector, it 
> shifts all larger keys. So dissoc would not only remove value at index 
> position, but also change keys for pther values. And this is not what 
> dissoc should do
>


You're right. I'm not sure why this is suddenly clear without essentially 
any new information. :) I think I had the wrong conceptual impression of 
what assoc and dissoc should be, putting the emphasis on the generality of 
the collection types instead its specificity to the indicies.

For my notion of assoc/dissoc to hold parity, it would have to work like 
this which seems undesirable:


(def some-vector ['a 'b 'c 'd 'e])
(def some-map {0 'a 1 'b 2 'c 3 'd 4 'e})

(assoc some-vector 2 'x)
;=> [a b x d e]
(dissoc some-vector 2) ;; theoretical
;=> [a b d e] ;; theoretical

(assoc some-map 2 'x)
;=> {0 a, 1 b, 2 x, 3 d, 4 e}
(dissoc some-map 2)
;=> {0 a, 1 b, 2 d, 3 e} ;; not good 

-- 
-- 
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en
--- 
You received this message because you are subscribed to the Google Groups 
"Clojure" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to clojure+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.

Reply via email to