Hey, how about this?
(defn first-non-nil
[xs]
(first (filter (complement nil?)
xs)))
On Fri, May 27, 2011 at 9:56 AM, MarisO <[email protected]> wrote:
> To find first defined Option in scala I do this:
>
> sol.find(_.isDefined).getOrElse(None)
>
> I managed to do the same in clojure:
>
> (some #(if (nil? %) false %) sol)
>
> Is there a better way ?
>
> --
> 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
--
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