Andrew J Bromage <[EMAIL PROTECTED]> wrote:
> G'day.

> On Mon, Mar 03, 2003 at 11:49:29AM +0200, Cagdas Ozgenc wrote:

> > Yes, I thought about these too. Do you find these functions
> > practically useful? Can you give an example where I can utilize
> > these functions?

> Functions like this are useful for plugging into higher-order
> functions to tailor them for your specific needs.

> Here's an artificial example:

>       length = sum . map (const 1)

Incidentally, here's another artificial example:

> indices = zipWith const [0..]

This can be used to define scanl, incidentally:

> scanl f z xn = [foldl f z (take i xn) | i <- indices (undefined:xn)]

(where the undefined: just reflects the fact that we want one more
element than xn has).

Jon Cast
_______________________________________________
Haskell-Cafe mailing list
[EMAIL PROTECTED]
http://www.haskell.org/mailman/listinfo/haskell-cafe

Reply via email to