Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
(defn fibo-volatile
[^long n]
(let [curr (volatile! 0N)
next (volatile! 1N)
iter (volatile! n)]
(while (> @iter 0)
(let [nnext (+ @curr @next)]
(vreset! curr @next)
(vreset! next nnext)
(vswap! iter dec)))
@curr))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment