Re: Newbie code review

2009-08-11 Thread Chad Harrington
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

Re: Newbie code review

2009-08-09 Thread Achim Passen
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

Re: Newbie code review

2009-08-09 Thread Jarkko Oranen
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