Hi,
When I stumbled upon the question "Clojure coalesce function" at
StackOverflow today, I saw a place for "reverted" maybe-m and
sequence-m monads. It seemed to have been easy, but turned out not. I
can't figure out how to use monads for the task at hand. Could someone
point me into a right direction? Here's what I've figured out so far.
(with-monad identity-m
(defn coalesce
[& xs]
(m-until #(not (nil? (first %))) rest xs)))
It doesn't return the first non-nil value, but merely starts with one
and moves on if there're more forms in xs.
Somehow I feel it's the usecase for monads, but without help chances
are I won't find the solution.
[1] http://stackoverflow.com/questions/4086889/clojure-coalesce-function
Jacek
--
Jacek Laskowski
Notatnik Projektanta Java EE - http://jaceklaskowski.pl
--
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to [email protected]
Note that posts from new members are moderated - please be patient with your
first post.
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en