scheme - Tail Call Elimination in Clojure? -


Can someone rewrite this (PLT) scheme code?

  (define) (define (hn) (printf "(h) (printf" (f ~ a) ~ n "n) (gn)) (defined (gn) (printf "(G ~ a) ~ n" n "(hn) ~ a) ~ n" n) (f (+ n 1)))  

Processes like this, And h to not collapse together and allow the code to run indefinitely without crashing?

Use trumpoline:

  declare f (defn H [n] (println "(g" n ")" # #)) (defl f [n] (defl g [n] (println "(h" n ") # (Println "(f" n ")") # (gn))  

Delete from:

  (Trampoline f 0)  

I have had to run this code on my PC for about 5 hours in the background and the memory usage is flat.


Comments

Popular posts from this blog

sql - dynamically varied number of conditions in the 'where' statement using LINQ -

asp.net mvc - Dynamically Generated Ajax.BeginForm -

Debug on symbian -