Hey all. I'm pretty new to Clojure, and wanted to try my hand at writing a macro.
'dowhile' is nothing special, but I'd still like to hear any comments/ suggestions you may have. (defmacro dowhile [body test] `(do ~body (while ~test ~body))) A test shows... (macroexpand-1 '(dowhile (dosync (alter x inc)) (< @x 5))) => (do (dosync (alter x inc)) (clojure.core/while (< (clojure.core/ deref x) 5) (dosync (alter x inc)))) And to show that it works... (def x (ref 0)) (println @x) ; 0 (dowhile (dosync (alter x inc)) (< @x 5)) (println @x) ; 5 (dowhile (dosync (alter x dec)) (> @x 7)) (println @x) ; 4 Thanks in advance. --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---