[Haskell-cafe] Re: Mapping over multiple values of a list at once?

Heinrich Apfelmus apfelmus at quantentunnel.de
Fri Aug 28 08:38:40 EDT 2009


haskell at kudling.de wrote:
> You are asked to iterate over the list and calculate the average value
> of each 3 neighbouring values.

Lambda Fu, form 72 - three way dragon zip

   averages3 xs = zipWith3 avg xs (drop 1 xs) (drop 2 xs)
       where avg a b c = (a+b+c) / 3



Regards,
apfelmus

--
http://apfelmus.nfshost.com



More information about the Haskell-Cafe mailing list