Skip to content

Instantly share code, notes, and snippets.

@wtakuo
Created May 9, 2014 10:23
Show Gist options
  • Save wtakuo/62373fc50a2498473332 to your computer and use it in GitHub Desktop.
Save wtakuo/62373fc50a2498473332 to your computer and use it in GitHub Desktop.
arbitrary precision e as a lazy list
-- arbitrary presision e as a lazy list
main = print $ take 1000 e
e = conv (2 : [1, 1 ..])
where
conv (x : xs) =
x : conv (norm 2 (0 : map (* 10) xs))
norm c (x : y : xs) =
if y + 9 < c then zs else carry c zs
where zs = x : norm (c + 1) (y : xs)
carry c (x : y : xs) =
x + div y c : mod y c : xs
@wtakuo
Copy link
Author

wtakuo commented Apr 20, 2017

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment