diff options
author | Rich Hickey <richhickey@gmail.com> | 2009-02-28 23:14:03 +0000 |
---|---|---|
committer | Rich Hickey <richhickey@gmail.com> | 2009-02-28 23:14:03 +0000 |
commit | 2fd3186c3502e34201a9803a1bb62bb7a9b01604 (patch) | |
tree | 206b060dfe51f91be69bac61171902310766d791 /src/clj | |
parent | 748c9ca640eb899b581fff479114b6cc3beade4c (diff) |
added letfn, supports mutually recursive local fns
Diffstat (limited to 'src/clj')
-rw-r--r-- | src/clj/clojure/core.clj | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/src/clj/clojure/core.clj b/src/clj/clojure/core.clj index 1b54f5e5..90566791 100644 --- a/src/clj/clojure/core.clj +++ b/src/clj/clojure/core.clj @@ -4047,3 +4047,14 @@ evaluated in parallel" [& exprs] `(pcalls ~@(map #(list `fn [] %) exprs))) + +(defmacro letfn + "Takes a vector of function specs and a body, and generates a set of + bindings of functions to their names. All of the names are available + in all of the definitions of the functions, as well as the body. + + fnspec ==> (fname [params*] exprs) or (fname ([params*] exprs)+)" + [fnspecs & body] + `(letfn* ~(vec (interleave (map first fnspecs) + (map #(cons `fn* %) fnspecs))) + ~@body)) |