I am glad it's helpful.I am using defun to write transform functions for instaparse in a DSL parser,it's really good at it.I am not sure if i can create a pull request to core.match.
发自我的 iPad > 在 2014年9月21日,下午5:13,Max Gonzih <gon...@gmail.com> 写道: > > Amazing! Would love to have something like that in clojure.core. > >> On Sunday, September 14, 2014 8:47:28 AM UTC+2, dennis wrote: >> >> Hi , i am pleased to introduce defun: a beautiful macro to define clojure >> functions with pattern match. >> >> Some examples: >> >> (defun say-hi >> ([:dennis] "Hi,good morning, dennis.") >> ([:catty] "Hi, catty, what time is it?") >> ([:green] "Hi,green, what a good day!") >> ([other] (str "Say hi to " other))) >> >> (say-hi :dennis) >> ;; "Hi,good morning, dennis." >> (say-hi :catty) >> ;; "Hi, catty, what time is it?" >> (say-hi :green) >> ;; "Hi,green, what a good day!" >> (say-hi "someone") >> ;; "Say hi to someone" >> >> Recursive function? It's all right: >> >> (defun count-down >> ([0] (println "Reach zero!")) >> ([n] (println n) >> (recur (dec n)))) >> (defun fib >> ([0] 0) >> ([1] 1) >> ([n] (+ (fib (- n 1)) (fib (- n 2))))) >> >> >> Guard functions? it's all right: >> >> (defun valid-geopoint? >> ([(_ :guard #(and (> % -180) (< % 180))) >> (_ :guard #(and (> % -90) (< % 90)))] true) >> ([_ _] false)) >> >> (valid-geopoint? 30 30) >> ;; true >> (valid-geopoint? -181 30) >> ;; false >> >> It's really cool,all the magic are from core.match, much more details please >> see >> https://github.com/killme2008/defun >> >> >> -- >> 庄晓丹 >> Email: killm...@gmail.com xzh...@avos.com >> Site: http://fnil.net >> Twitter: @killme2008 >> >> > > -- > 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 > --- > You received this message because you are subscribed to the Google Groups > "Clojure" group. > To unsubscribe from this group and stop receiving emails from it, send an > email to clojure+unsubscr...@googlegroups.com. > For more options, visit https://groups.google.com/d/optout. -- 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 --- You received this message because you are subscribed to the Google Groups "Clojure" group. To unsubscribe from this group and stop receiving emails from it, send an email to clojure+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.