Created
June 4, 2010 12:24
-
-
Save cgrand/425352 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(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)))))))) | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
(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)))