I hereby claim:
- I am paulhobbs on github.
- I am paulhobbs (https://keybase.io/paulhobbs) on keybase.
- I have a public key ASBNYmmkDYxq6HfKp9nZ8LJEgHaxXg7HDiWHtUa_-qd16Ao
To claim this, I am signing this object:
I hereby claim:
To claim this, I am signing this object:
(require '(clojure [zip :as zip])) | |
(defn memoize-calls | |
"Takes an expression, and replaces calls to func with cache checks, and calls | |
if cache is missing." | |
([func cache expr] (memoize-calls func cache expr (zip/seq-zip expr))) | |
([func cache expr pos] | |
(if (zip/end? pos) (zip/root pos) ; if at the end, return the tree. | |
(if (and (= func (zip/node pos)) | |
(empty? (zip/lefts pos))) |
(defn vrange2 [n] | |
(loop [i 0 v (transient [])] | |
(if (< i n) | |
(recur (inc i) (conj! v i)) | |
(persistent! v)))) | |
;; Slower!? | |
(defn vrange3 [n] | |
(loop [ i (int 0) v (transient [])] | |
(if (< i n) |