On Mon, Aug 25, 2008 at 8:45 AM, Stuart Halloway <[EMAIL PROTECTED]> wrote: > > (defn keys-with-value-matching [map test-fn] > (for [pair (map identity map) :when (test-fn (last pair))] > (first pair))) > > (defn basic-colors-in [color] > (keys-with-value-matching color (comp not zero?)))
I'm not sure why you used "(map identity map)" instead of just "map", but other than that I think the only major idiom you're missing is destructuring, which tidies this up a bit: (defn basic-colors-in [color] (for [[k v] color :when (not= v 0)] k)) Maybe others can spot more simplifications. > (defmulti color-string basic-colors-in) I don't feel qualified to comment on this use of multimethods, or multimethods at all really. I simply wouldn't have thought of using them in this case, but maybe it's fine. Maybe it's even great, I don't know. :-) --Chouser --~--~---------~--~----~------------~-------~--~----~ 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 [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/clojure?hl=en -~----------~----~----~----~------~----~------~--~---