Create a gist now

Instantly share code, notes, and snippets.

(definterface IntToIntFn
(#^int call [^int n]))
(def fibr
(let [one (int 1)
two (int 2)]
(reify
IntToIntFn
(call [this n]
(if (>= one n) one (+ (.call this (dec n)) (.call this (- n two))))))))
(def fibr
(reify
IntToIntFn
(call [this n]
(if (>= (int 1) n) (int 1) (+ (.call this (dec n)) (.call this (- n (int 2))))))))
@richhickey

(definterface IFib
(^int fib [^int n]))

(deftype Fib []
IFib
(fib [this n](if %28>= %28int 1%29 n%29 %28int 1%29 %28+ %28.fib this %28dec n%29%29 %28.fib this %28- n %28int 2%29%29%29%29)))

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment