read


read
or learn more

Recursion is a low-level operation

Mar 9, 2011 some comments

Yesterday I demonstrated how to transform a mundane recursive function into a tail recursive function. However, I received some flak for that post because there are better ways to implement run-length encoding with Clojure. While certainly true, I think some of my critics1 missed the point of the exercise. ;-) Having said that; their points […]

Transforming an accumulating mundane recursive fn into a tail-recursive fn (with Clojure)

Mar 8, 2011 some comments

this example is in Clojure, but the general principle stands regardless of language Transforming an accumulating mundane recursive function to a tail-recursive function using a helper function. (defn mundane-pack “Mundane recursive way to pack a sequence” [[f & r :as S]] (if (seq S) (let [[packed tail] (split-with {f true} S)] (if (seq tail) (cons […]

Continue