Hi, Am 18.11.2008 um 17:29 schrieb [EMAIL PROTECTED]:
What could be some good strategies to adapt the code I have here to Clojure, where tail calls are not eliminated and structs are not lazy?
There is the lazy-map package[1], which also allows lazy (struct)maps. However it is not updated to 1094+, yet. I only skimmed through your code and I don't know the paper, but maybe I can give some general tips. As always: don't copy code blindly! Take a step back and look from a distance, how you can *translate* the code. For example, in the show-list-children function, the recursion is just used for iteration. It starts with x, do something to (first x) and then calls itself with (rest x). So the first step is to translate this into a loop recur pair. The next step is to see, that one can also write this as (doseq [child x] (do-something-to x)), or in case its the result you are interested in and not the side-effects: (map #(do-something-to %) x). So don't just copy the code, but understand what it does and then ask: "how would I do this in Clojure?" Stuart's "PCL goes Clojure" series[2] is great example for this. Just my 2ยข. Sincerely Meikel [1]: http://kotka.de/projects/clojure/lazy-map.html [2]: http://blog.thinkrelevance.com/2008/9/16/pcl-clojure
smime.p7s
Description: S/MIME cryptographic signature