Hi Steve, I didn't know the difference between a keyfn and a comparator. Thanks for pointing that out!
Kev On Jun 22, 3:50 pm, "Stephen C. Gilardi" <squee...@mac.com> wrote: > On Jun 22, 2009, at 1:23 AM, kkw wrote: > > > I had some fortune with the sorted-by function: > > > 1:11 user=> (sort-by (fn [e] (second e)) [[1 99] [3 4] [5 6] [7 8]]) > > ([3 4] [5 6] [7 8] [1 99]) > > You were using the form of sort-by that accepts a "keyfn", not the one > where you also provide a comparator. > > > so I thought I'd have a go with sorted-map-by also: > > > 1:13 user=> (doc sorted-map-by) > > ------------------------- > > clojure.core/sorted-map-by > > ([comparator & keyvals]) > > keyval => key val > > Returns a new sorted map with supplied mappings, using the supplied > > comparator. > > > 1:14 user=> (sorted-map-by (fn [c] c) 1 2) > > {1 2} > > No comparisons were necessary, so your comparator function wasn't > called. > > > 1:16 user=> (sorted-map-by (fn [c] c) 1 2 3 4) > > java.lang.RuntimeException: java.lang.IllegalArgumentException: Wrong > > number of args passed to: user$eval--85$fn (repl-1:16) > > sorted-map-by called your comparator, but comparators take two > arguments and your function only accepts one. > > --Steve > > smime.p7s > 3KViewDownload --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---