
On Monday, July 09, 2012 18:01:49 Carlos J. G. Duarte wrote:
underK k (x:xs) = (if x < k then [x] else []) ++ underK k xs
-- from [2] ... how does this work anyway? fibs = 0 : 1 : zipWith (+) fibs (tail fibs) Which seems to work ok. How is takeWhile stopping at a given point and my underK not? Look. In your implementation `underK' you *always* call itself. So, actually you implemented filter. takeWhile can be implemented(you can easily see source http://www.haskell.org/ghc/docs/latest/html/libraries/base/Data-List.html. Take notion that takeWhile do not call itself anymore if predicate is false.
Other question is regarding the "$" and ".". I know the $ has lower priority and . has more, but is there any more difference that matters, I mean, can I always use the "$" everywhere. For example, this main also works: main = putStrLn $ show $ sum $ filter even $ takeWhile (<_M) fibs Is it doing the same thing? It only affect amount of parensisis. Point is nice for high-order function magic. -- Best regards, illusionoflife. This mail is for mailing lists. For private, responce-warrantied mail use illusion.of.life92@gmail.com.