Last active
October 9, 2015 10:56
-
-
Save erantapaa/32d13c4b59399bcd0b63 to your computer and use it in GitHub Desktop.
ordlist example
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
A gist collecting examples of how to use `Data.List.Ordered` | |
> import Data.List.Ordered | |
Sieve of Eratosthenes | |
=== | |
From the Haskellwiki entry on the [Sieve of Eratosthenes][HaskellWikiSieve]: | |
> primes = 2 : 3 : ([5,7..] `minus` unionAll [[p*p, p*p+2*p..] | p <- tail primes]) | |
Hamming Numbers | |
=== | |
Hamming numbers are numbers of the form 2^i*3^j*5^k. | |
Generating the Hamming numbers in order: | |
> hamming = 1 : unionAll [ map (2*) hamming, map (3*) hamming, map (5*) hamming ] | |
See also the Rosetta Code entry for [Hamming numbers][RosettaCodeHamming]. | |
[HaskellWikiSieve]: https://wiki.haskell.org/Prime_numbers#Sieve_of_Eratosthenes | |
[RosettaCodeHamming]: http://rosettacode.org/wiki/Hamming_numbers#The_classic_version | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment