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

Reply via email to