(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"
(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)))))
(defun valid-geopoint?([(_ :guard #(and (> % -180) (< % 180)))(_ :guard #(and (> % -90) (< % 90)))] true)([_ _] false))(valid-geopoint? 30 30);; true(valid-geopoint? -181 30);; false
(defun accum ([0 ret] ret) ([n ret] (recur (dec n) (+ n ret))) ([n] (recur n 0))) (accum 100) ;; the result is 5050
(macroexpand-1'(defun accum
([0 ret] ret)([n ret] (recur (dec n) (+ n ret)))
([n] (recur n 0))))=>(clojure.core/defnaccum{:arglists '([0 ret] [n ret] [n])}[& args__4602__auto__](clojure.core.match/match[(clojure.core/vec args__4602__auto__)][[0 ret]](do ret)[[n ret]](do (recur (vector (dec n) (+ n ret))))[[n]](do (recur (vector n 0)))))
--
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clo...@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+u...@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+u...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Friendly advice: when you describe anything you create with adjectives like beautiful, it comes off as unnecessarily arrogant to native English speakers.Adrian
Hi , i am pleased to introduce defun: a beautiful macro to define clojure functions with pattern match.
[snip]
--
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clo...@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+u...@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+u...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.