That would work for replacing a single cond surrounded by a single let, but I often find myself writing a series of nested lets, when- lets, if-lets, etc. to handle the exceptional cases in lets. A contrived example:
(when-let [a foo] (let [b bar] (when (even? b) (let [c baz] (when (> b c) (let [d qux] (f a b c d))))))) becomes: (let? [a foo :else nil b bar :is even? c baz :when (> b c) d qux] (f a b c d)) On Mar 8, 1:24 pm, evandi <evan135...@gmail.com> wrote: > Why not avoid all the keywords and create let-cond? > > (let-cond [a x b (* a 4)] > (> b x) 1 > :else 2) > > > > > > > > On Thursday, March 8, 2012 9:01:33 AM UTC-8, Evan Gamble wrote: > > > Another way to flatten nested lets and conds is to use a macro that > > lets you insert conditionals in your lets (vs. your suggestion of > > inserting lets in conds). > > > I wrote a let? macro that does that:https://github.com/egamble/let-else > > > - Evan > > > On Mar 7, 10:51 pm, Mark Engelberg <mark.engelb...@gmail.com> wrote: > > > > In the meantime, I *strongly urge* everyone to check out Grand's flatter > > > cond macro: > >https://github.com/cgrand/parsley/blob/master/src/net/cgrand/parsley/... > > > > It lets you insert lets in the middle of cond expressions (like you can > > > currently do with for) like: > > > (cond > > > (pos? x) 2 > > > :let [y (* x x)] > > > (> y 20) 4)) > > > > This totally transformed my coding style and improved the readability of > > my > > > code substantially. Highly recommended. Since it is backwards > > compatible, > > > I very much wish it were part of the core, and see no reason that it > > > couldn't be. > > > > --Mark -- 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