Skip to content

Instantly share code, notes, and snippets.

@aanand
Last active December 14, 2015 04:59
Show Gist options
  • Save aanand/5031784 to your computer and use it in GitHub Desktop.
Save aanand/5031784 to your computer and use it in GitHub Desktop.
Un-genuine Sieve of Eratosthenes in Haskell
$ ghci sieve.hs
*Main> take 10 primes
[2,3,5,7,11,13,17,19,23,29]
primes = sieve [2..]
sieve (x:xs) = x : sieve [n | n <- xs, n `mod` x > 0]
@aanand
Copy link
Author

aanand commented Feb 25, 2013

Nice find Reg. I love that the example code is identical to the one I typed from memory (disregarding whitespace and variable identifiers).

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