[Haskell-cafe] Function composition confusion

Henning Thielemann lemming at henning-thielemann.de
Wed Apr 27 09:37:19 EDT 2005


On Wed, 27 Apr 2005, Anuj Seth wrote:

> Excuse the newbie'ness of my question.
> Saw an example in Two Dozen Questions by Rexx Page.
>
> blocks blockSize =
>    takeWhile ( not . null ) . map fst .
>              iterate (splitAt blockSize . snd) . splitAt blockSize
>
> What is the meaning of the . operators outside the parentheses ?

The same as inside. :-)
  (splitAt blockSize) transforms a list to a pair of lists. So imagine a 
list input at the right of (splitAt blockSize) and a pair output at the 
left. This pair is piped into the 'iterate' part which transforms a list 
of pairs into a list of pairs of lists. This in turn is piped to (map fst) 
and so on.


More information about the Haskell-Cafe mailing list