That works, but I don't think it's satisfactory. first and second
aren't the intended functions to access a map entry's keys and vals—
but most importantly, it's been documented that second is very, very
slow compared to val (http://w01fe.com/blog/2009/01/more-on-clojure-
map-accessor-speeds/). sec
Just use first and second for both cases.
On Nov 11, 9:52 am, samppi wrote:
> Clojure 1.1.0-alpha-SNAPSHOT
> user=> (conj (first {1 2}) 3)
> [1 2 3]
> user=> (conj {1 2} [2 5])
> {2 5, 1 2}
> user=> (key (first {1 2}))
> 1
> user=> (key [1 2])
> java.lang.ClassCastException: clojure.lang.Persist
Clojure 1.1.0-alpha-SNAPSHOT
user=> (conj (first {1 2}) 3)
[1 2 3]
user=> (conj {1 2} [2 5])
{2 5, 1 2}
user=> (key (first {1 2}))
1
user=> (key [1 2])
java.lang.ClassCastException: clojure.lang.PersistentVector cannot be
cast to java.util.Map$Entry (NO_SOURCE_FILE:0)
In all respects but one, two-