read


read
or learn more

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