[Haskell-cafe] Composition and type magic

Michael Orlitzky michael at orlitzky.com
Tue Feb 24 03:27:33 UTC 2015


On 02/23/2015 10:11 PM, Sumit Sahrawat, Maths & Computing, IIT (BHU) wrote:
> Hi everyone,
> 
> I defined a function for discrete convolution, i.e
> 
>     conv xs = sum . zipWith (*) xs . reverse
> 
> And I was wondering, can it be done without explicitly passing in the xs
> (eta-reduction)?

Ehhhhhhhhhh this will work:

  conv = (sum .) . (. reverse) . zipWith (*)

But it's so much easier to understand without all the boobies operators:

  conv xs ys = sum $ zipWith (*) xs (reverse ys)



More information about the Haskell-Cafe mailing list