The intent of the mapping can be made clearer with destructuring I
> think. Also, flatten is not needed: a core function called "into" will
> transform a sequence of key/value pairs into a map.
>
> (def age-index
> (into (sorted-map)
>(map (fn [[k [name age]]] [age k]) data)))
>
Jarkko,
Than
Hi!
If you'd like to use relational structures, take a look at
clojure.set. There's a couple of functions which let you do relational
algebra (project, select, rename, plus some other things like index).
Clojure represents relations as sets of maps:
(def data #{{:id 0 :name "Fred":age 3
On Aug 9, 9:27 am, Chad Harrington wrote:
> Hi all,
> I am learning Clojure and would like to see if there is a better/more
> concise/faster/more idiomatic/etc. way to create the age-index below. My
> version seems awfully roundabout. The basic concept is a toy database table
> stored as a hashm