Thank you. This will take some time for me to read.On Fri, Dec 19, 2014 at 12:32 PM, Lyndon Maydwell <maydwell@gmail.com> wrote:funB = flip takeWhile primes . ( . join (*)) . flip (<=)funB x = flip takeWhile primes ((( . join (*)) . flip (<=)) x)funB x = takeWhile ((( . join (*)) . flip (<=)) x) primesfunB x = takeWhile (foo x) primesfoo x = (( . join (*)) . flip (<=)) xfoo x = (( . join (*)) (flip (<=) x)foo x = flip (<=) x . join (*)foo x = (x <=) . join (*)-- join :: Monad m => m (m a) -> m a-- join (*) == (**2)foo x = (x <=) . (** 2)foo x y = x <= (y ** 2)isLessThanTheSquareOf = foofunB x = takeWhile (x `isLessThanTheSquareOf`) primesHelpful?On Fri, Dec 19, 2014 at 2:52 PM, Magicloud Magiclouds <magicloud.magiclouds@gmail.com> wrote:_______________________________________________Hi,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.import Control.MonadisPrime :: Integer -> BoolisPrime i = ap funA funB ifunA :: Integer -> [Integer] -> BoolfunA x xs = all (\x' -> (mod x x') /= 0) xsfunB :: Integer -> [Integer]funB = flip takeWhile primes . ( . join (*)) . flip (<=)primes :: [Integer]primes = 2 : filter isPrime [3, 5 ..]main :: IO ()main = print $ take 10 primes--
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe
--
_______________________________________________
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe