Skip to content

Instantly share code, notes, and snippets.

@rlm
Created December 19, 2010 18:31
Show Gist options
  • Save rlm/747571 to your computer and use it in GitHub Desktop.
Save rlm/747571 to your computer and use it in GitHub Desktop.
an example of recursion with re-dispatch on multimethods
(defmulti redis class)
(defmethod redis java.lang.Integer [x] x)
(defmethod redis java.lang.Double [x]
(let [res (if (< (- x (int (floor x))) 0.01)
(int x)
(/ x 2))]
(println x)
(fn [] ((get-method redis ((.dispatchFn redis) res)) res))
))
;; call like this:
(trampoline redis 64.05)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment