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

2009-08-28 Thread Jon Fairbairn
Raynor Vliegendhart writes: > Just wondering, what should be the expected output be of something > like mavg 4 [1..3]? [3%2] or []? [0%1, 1%4, 3%4, 3%2, 3%2, 5%4, 3%4, 0%1], of course ;-P -- Jón Fairbairn jon.fairba...@cl.cam.ac.uk ___

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

2009-08-28 Thread Heinrich Apfelmus
hask...@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 -- htt