On 12 February 2010 03:19, Martin Hauner <martin.hau...@gmx.net> wrote: > I'm mostly interested if there is anything in my code one would/should > never do that way.
Looks excellent, you've aced it! I'd like to discuss switching... You wrote: (cond (empty? rolls) 0 (strike? rolls) (+ (score-strike rolls) (score-after-strike rolls)) (spare? rolls) (+ (score-spare rolls) (score-after-frame rolls)) (more? rolls) (+ (score-frame rolls) (score-after-frame rolls))) Which is correct and very readable. If I wanted a DRYer expression: (condp #(%1 %2) rolls empty? 0 strike? (+ (score-strike rolls) (score-after-strike rolls)) spare? (+ (score-spare rolls) (score-after-frame rolls)) more? (+ (score-frame rolls) (score-after-frame rolls))) But the #(%1 %2) is ugly and not immediately obvious how it works. Would it be any nicer if we defined a function-name? or made a switchp which hides that part? Or use a trick: (condp apply [rolls] .... ....) I've found myself faced with this particular DRY vs clear trade-off and never been sure what to do! Regards, Tim. -- 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