[Haskell-cafe] Question on Exercise from SOE

Henning Thielemann iakd0 at clusterf.urz.uni-halle.de
Mon Jul 5 08:24:11 EDT 2004


On Sat, 3 Jul 2004, Nathan Weston wrote:

> My first thought is to use fold here, since this function accumulates a result 
> as it traverses the list. But fold consumes one element of the list at a 
> time, while area needs to examine the first three elements of the list, and 
> consume two of them at a time.
> Is there a more general alternative to fold? Or is there some trick I'm 
> missing here?

What's about zipping delayed versions of the list, say
 zipWith3 (calcArea) v (tail v) (tail (tail v))  ? 





More information about the Haskell-Cafe mailing list