There's a couple of Fibonacci's on the wiki that uses this approach:
http://en.wikibooks.org/wiki/Clojure_Programming/Examples#Lazy_Fibonacci

On Mon, Feb 16, 2009 at 6:50 PM, Konrad Hinsen
<konrad.hin...@laposte.net> wrote:
>
> I just discovered a nice feature that I don't remember having seen
> discussed or documented before: there is a way to write recursive
> functions without having them associated to any var/symbol in any
> namespace. The optional name of a function can be used for a
> recursive call. Example:
>
> ((fn fac [n] (if (zero? n) 1 (* n (fac (dec n))))) 5)
>
> I know this is not the best way to write a factorial (it is not tail-
> recursive), the point is just to show an example of a recursive call.
>
> Konrad.
>
> >
>



-- 
Venlig hilsen / Kind regards,
Christian Vest Hansen.

--~--~---------~--~----~------------~-------~--~----~
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
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
-~----------~----~----~----~------~----~------~--~---

Reply via email to