+1 for some-> and some->>.
I use this all the time in my coding. They used to be -?> and -?>> in
clojure.core.incubator, so I'm extremely happy that they finally made their
way into core proper.
On Saturday, March 23, 2013 7:25:00 PM UTC-4, Evan Gamble wrote:
>
> The let? macro addresses such s
The let? macro addresses such
situations: https://github.com/egamble/let-else
--
--
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
Your maybe-> does almost the same thing as Clojure 1.5's some-> but without
support for naked fns (like `(some-> 1 inc)`). It also evaluates each
"step" but the last twice (once for the `if`, once when inserted after
`op`).
If you don't want to switch to some->, I'd recommend you use when-let to
a
I've recently had a need for something like that in my own code. The
"real" solution to that problem in the functional programming world is
known as the maybe monad. Since I just needed a quick and dirty
solution and I have not wrapped my head around monads yet, here's what
I did :
(defmacro maybe
You can get quite a long way with just "if-let" "and" and "or" to express
the bailout logic.
Examples I find myself using all the time:
;; fallback / default values
(or (maybe-make-value) (make-fallback-value) (error "this shouldn't
happen!"))
;; bailout with nil return (assumes you are runnin
2013/3/23 Russell Mull
> Which leads me to my question: does such a construct already exist? Or
> perhaps am I doing it wrong? I've googled around for this, but I'm not
> exactly sure what it's called.
http://clojuredocs.org/clojure_core/clojure.core/if-let (and its close
relative when-let).
E
Hi Clojurians,
I'm relatively new to the language and am trying to get used to its idioms.
One thing I'm accustomed to doing in things like java and C# is checking
values for validity and then bailing out early if they don't make sense.
For example, without this idiom in java you might do:
O