Skip to content

Instantly share code, notes, and snippets.

@cgrand
Created June 4, 2010 12:24
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save cgrand/425352 to your computer and use it in GitHub Desktop.
Save cgrand/425352 to your computer and use it in GitHub Desktop.
(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
Copy link

(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