SHARE
TWEET

Untitled

a guest Sep 8th, 2010 101 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. (defn fibs
  2.   ([]
  3.      (fibs 0 nil nil))
  4.   ([n val1 val2]
  5.      (lazy-seq
  6.       (let [val3 (condp = n 0 0, 1 1, (+ val1 val2))]
  7.         (cons val3
  8.             (fibs (inc n) val2 val3))))))
  9.  
  10. (defn fib
  11.   [n]
  12.   (->> (fibs)
  13.       (drop n)
  14.       first))
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top