[Haskell-cafe] Could someone help me to understand funB?
magicloud.magiclouds at gmail.com
Fri Dec 19 03:52:48 UTC 2014
Following code is to get a list of primes. Now it is hard for me to
understand funB. I mean I can see what it does. But I cannot see the
detailed process by every language part.
isPrime :: Integer -> Bool
isPrime i = ap funA funB i
funA :: Integer -> [Integer] -> Bool
funA x xs = all (\x' -> (mod x x') /= 0) xs
funB :: Integer -> [Integer]
funB = flip takeWhile primes . ( . join (*)) . flip (<=)
primes :: [Integer]
primes = 2 : filter isPrime [3, 5 ..]
main :: IO ()
main = print $ take 10 primes
And for G+, please use magiclouds#gmail.com.
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the Haskell-Cafe