Skip to content

Instantly share code, notes, and snippets.

View joehakimrahme's full-sized avatar

Joe H. Rahme joehakimrahme

  • Red Hat
  • Milano
View GitHub Profile
@omaraboumrad
omaraboumrad / singledispatch.py
Last active December 23, 2015 08:19
Poor man's singledispatch
# Define
def singledispatch(func):
through_map = {}
def register(through):
def _on(what):
through_map[through] = what
return what
return _on
def dispatch(what):
(defn fib []
(setf a 0)
(setf b 1)
(while true (yield a) (setf (, a b) (, b (+ a b)))))
(setf it (fib))
(for [x (range 10)]
(print (next it)))