On Mon, May 21, 2012 at 8:54 AM, Christian Guimaraes <cguimaraes...@gmail.com> wrote: > What is the better approach (or functional approach) to work with a code > like the below?
A simple translation to condp: (defn parse-group [group-identifier line] (condp = group-identifier "ID1" (handle-id1 line) "ID2" (handle-id2 line) "ID3" (handle-id3 line))) But you may want something more extensible: (def group-handlers {"ID1" handle-id1, "ID2" handle-id2, "ID3" handle-id3}) (defn parse-group [group-identifier line] (if-let [handler (group-handlers group-identifier)] (handler line) (println "unknown group identifier"))) A multimethod might also be an appropriate way forward for you. -- Sean A Corfield -- (904) 302-SEAN An Architect's View -- http://corfield.org/ World Singles, LLC. -- http://worldsingles.com/ "Perfection is the enemy of the good." -- Gustave Flaubert, French realist novelist (1821-1880) -- 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 patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en