3 ms·
I think I'd normally say "read SICP" but Clojure discourages recursion in favor of it's looping constructs (due to the non-ability to optimize it on the JVM I'm
by apgwoz 17y ago
I think I'd normally say "read SICP" but Clojure discourages recursion in favor of it's looping constructs (due to the non-ability to optimize it on the JVM I'm guessing).
That said, SICP will still teach you to think in terms of HOFs and functions as abstractions, so it'll definitely help out. And it's free online, so the only investment is time.
- sctb 17y agoI believe that you can replace directly recursive tail-calls with the `recur' special form to achieve an iterative function manually. If the function is truly recursive, then Clojure will likely behave much as any Scheme would.
- apgwoz 17y agoI haven't looked at the code that gets generated by `recur`, but I'm guessing it creates a trampoline, and it looks a bit limiting. (e.g. you can't recur with variadic functions) That said, probably all of the excercises in SICP could be done with `recur` and `loop,` with a few minor changes. Thanks for the tip.