Thanks, Evan; I had a use-case where the truthiness of nil would have
forced me out of `let-else.' This new predicate-abstraction is
beautiful.
Quoth Evan Gamble on Sweetmorn, the 49th of The Aftermath:
> Thanks for your comment, Sam.
>
> Before you posted the comment, Peter Danenberg had asked i
Stephen Compall writes:
> And may be anyway further generalized:
>
> (defmacro <<- [& forms]
> `(->> ~@(reverse forms)))
>
> (<<- (let [x (foo) y (bar)])
> (when y)
> (let [ ])
> (do ))
Another alternative,
(require '[clojure.algo.monads :as m])
(m/domonad m/maybe-m
On Tue, 2011-12-06 at 19:13 -0800, Sam Ritchie wrote:
> (let [x (foo)
> y (bar)]
> (when y
>(let [ ]
>)))
>
> that check jarred me, so I put this together:
> https://gist.github.com/1347312. On reflection, discomfort with indentation
> levels probably isn't n
Thanks for your comment, Sam.
Before you posted the comment, Peter Danenberg had asked if I would
modify let-else to include the behavior of your let? macro. Your
comment and his request have spurred me to action.
I've modified the macro to accept optional :when and :else
clauses after bindings
I had a pattern that kept popping up in code of:
(let [x (foo)
y (bar)]
(when y
(let [ ]
)))
that check jarred me, so I put this together:
https://gist.github.com/1347312. On reflection, discomfort with indentation
levels probably isn't near the top of the "to
I noticed in my code that I often nest a let inside an if-let, or vice-
versa, so I wrote a macro let-else that expands into nested lets,
except where there's an :else after a binding, in which case
that binding expands into an if-let.
E.g.
(let-else
[foo (f1) :else (e)
bar (f2)]
(b1)
(