-
-
Save wtakuo/62373fc50a2498473332 to your computer and use it in GitHub Desktop.
arbitrary precision e as a lazy list
This file contains hidden or 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
-- 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 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
http://ideone.com/uFfZHN