Skip to content

Instantly share code, notes, and snippets.

@dsp
Created June 17, 2010 13:21
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dsp/442107 to your computer and use it in GitHub Desktop.
Save dsp/442107 to your computer and use it in GitHub Desktop.
(defn q
([a x]
(* 1/2 (+ x (/ a x)))))
(defn lazy-q
([a] (concat [a] (lazy-q a a)))
([a x]
(let [r (q a x)]
(lazy-seq
(cons r
(lazy-q a r))))))
(println (map double (take-nth 30 (partial lazy-q 1/2))))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment