This does work quite nicely with trampoline, though:
(letfn [(a [n] #(if (zero? n) n (b (dec n))))
(b [n] #(if (zero? n) n (c (dec n))))
(c [n] #(if (zero? n) n (a (dec n))))]
(trampoline c 100000))
> I've added letfn, which lets you define mutually recursive local
> functions a la CL's labels.
> (defn ring [n]
> (letfn [(a [n] (if (zero? n) n (b (dec n))))
> (b [n] (if (zero? n) n (c (dec n))))
> (c [n] (if (zero? n) n (a (dec n))))]
> (c n)))
I noticed that letfn does not permit destructuring in its argument
(letfn [(a [[f & r]] f)]
(a [1 2 3]))
java.lang.IllegalArgumentException: fn params must be Symbols
Is this intentional?
Fixed in svn 1317 - thanks for the report.
Do you advocate usage of 'letfn' and 'let' similar to the distinction
between LABELS and FLET in CL? In other words, FLET implies non-
recursive local function definition whereas LABELS suggests
(mutually) recursive function(s).
(letfn [(f [x] (+ x 2))] (f 8)) ; LABELS
should ideally be:
(let [f (fn [x] (+ x 2))] (f 8)) ; FLET