This isn't fully tested, but it should work.  Lisp doesn't need
fixing.

(defmacro switch [choice-seq & clause-maps]
  (let [choice (first choice-seq)
        clauses (map #(apply concat %) clause-maps)]
    `(condp = ~choice ~@(apply concat (map (fn [clause]
                                      [(first clause) `(do ~@(next clause))]) 
clauses)))))

user> (macroexpand-1 '(switch (choice)
    {my-choice
        (having-fun)
    }
    {(your-choice)
        (being-pragmatic)
    }
    {(their-choice)
        (lisp-is-not-for-everyone)
    }) )
(clojure.core/condp clojure.core/= choice my-choice (do (having-fun))
(your-choice) (do (being-pragmatic)) (their-choice) (do (lisp-is-not-
for-everyone)))

-- 
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

Reply via email to