Hi PH, > "Returns a map of the elements of col to the evaluation of function
(zipmap keys (map fun keys)) http://groups.google.com/group/clojure/browse_thread/thread/8fe99ca560c4515/9721d59987207241?lnk=gst&q=zipmap#9721d59987207241 If you are following Matt's suggestion of a sorted map though then you might need something a bit more complex: "(sorted-map-by comparator & keyvals)" where comparator would probably sort by x then y, you can generate you keyvals like so: (interleave keys (map fun keys)) user=> (def ks [1 2 3]) user=> (defn f [x] (+ x 1)) user=> (apply sorted-map-by < (interleave ks (map f ks))) {1 2, 2 3, 3 4} user=> (zipmap ks (map f ks)) {3 4, 2 3, 1 2} (note that < is not really necessary as is the default) There are lots of ways to construct maps eg: user=> (into {} [[1 2] [3 4]]) {3 4, 1 2} user=> {1 2 3 4} {1 2, 3 4} user=> (hash-map 1 2 3 4) {1 2, 3 4} Regards, Tim. On Feb 11, 8:52 am, phtrivier <phtriv...@gmail.com> wrote: > Okay, can I ask exactly how you produce the map ? In my situation I > know how to compute whether a cell [i,j] is blocked, I can generate > the list of couples [i,j] that suits me ... and then I am stuck, not > knowing with function / macro to call. I guess it's just the same > problem as with cond, I am pretty sure their is a function that does > just that, but I don't have a clue how it's called ;) what I am > looking for is : > > foobar [f col] > "Returns a map of the elements of col to the evaluation of function > f on each of them" > > For some value of foobar ... I tried google all functions starting > with "Returns a map", but I had no luck .... it is some usage of map ? > of assoc itself in a way that I haven't tried ? --~--~---------~--~----~------------~-------~--~----~ 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 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 -~----------~----~----~----~------~----~------~--~---