here is my entry

(defn pure-loop [n]
  (println "pure " n)
  (if (= n 0)
    0
    #(danger-loop (dec n))))

(defn danger-loop [n]
  (println "danger " n)
  (if (= n 0)
    0
    #(pure-loop (dec n))))



user=> (trampoline pure-loop 20)
pure  20
danger  19
pure  18
danger  17
pure  16
danger  15
pure  14
danger  13
pure  12
danger  11
pure  10
danger  9
pure  8
danger  7
pure  6
danger  5
pure  4
danger  3
pure  2
danger  1
pure  0


It's strange because, well, to use trampoline to do a decreasing loop
is very strange indeed.

-- 
You received this message because you are subscribed to the Google Groups "The 
Java Posse" group.
To post to this group, send email to javapo...@googlegroups.com.
To unsubscribe from this group, send email to 
javaposse+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/javaposse?hl=en.

Reply via email to