On Sat, Nov 5, 2011 at 11:55 AM, Martin DeMello <martindeme...@gmail.com> wrote: > What's the cleanest way to run a piece of code if any branch of a cond > statement succeeded, without relying on the return value of the > individual clauses not to be nil? > > For example, if I have the following piece of code that says I can > only move left or up > > (cond > (= dir :left) (move-left) > (= dir :up) (move-up)) > > but (move-left) or (move-up) could themselves return nil, is there any > nice way to check if one of them was called?
What about something like this - (cond (= dir :left) (move-left) (= dir :up) (move-up) :else :nok) Or (cond (= dir :left) [(move-left)] (= dir :up) [(move-up)]) Regards, BG -- Baishampayan Ghose b.ghose at gmail.com -- 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