On May 21, 2012, at 10:54 AM, Christian Guimaraes wrote:
> I'm struggling with "when" code structures and my imperative mindset.
>
> What is the better approach (or functional approach) to work with a code like
> the below?
I think you're looking for cond (from memory, syntax might be wrong):
(defn parse-group [group-identifier line]
(cond
(= group-identitifer "ID1") (handle-id1 line)
...
:else (do-something)))
etc
(doc cond) will give you what you need I think
bill
> (defn parse-group [group-identifier line]
> (when (= group-identifier "ID1")
> (handle-id1 line))
> (when (= group-identifier "ID2")
> (handle-id2 line))
> (when (= group-identifier "ID3")
> (handle-id3 line)))
--
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