well, do you want to know how to find 'prime numbers' in a quick and dirty
way using Haskell ?
try this!
import Data.List
nubBy ( \x y -> mod y x == 0 ) [2..]
Haskell is so easy and charming...
( ps: if you want to speed up a little bit:
nubBy ( \x y -> ( x*x-1 <= y ) && ( mod y x == 0 ) ) [2..]
)
martedì 8 dicembre 2009
Prime Numbers in haskell
Iscriviti a:
Commenti sul post (Atom)
1 commento:
even better:
nubBy(((.).(.))(0==) (flip $ mod)) [2..]
Posta un commento