Nice!

Just out of curiosity...

I have no trouble accepting that the zipWith3 approach is more idiomatic, but it doesn't appear (to my eye) significantly shorter or significantly more obvious. So are the tradeoffs primarily cultural, or is there another issue that I'm missing?

Thanks,
-jn-

On Sat, Feb 21, 2015 at 12:04 PM, Chaddaï Fouché <chaddai.fouche@gmail.com> wrote:
On Sat, Feb 21, 2015 at 4:50 PM, Joel Neely <joel.neely@gmail.com> wrote:

smooth :: Fractional n => [n] -> [n]
smooth (a:z@(b:c:_)) = (a + b + c) / 3 : smooth z
smooth _             = []


In Haskell, I would write this with higher-order functions though :

smooth xs = zipWith3 (\a b c -> (a+b+c)/3) xs (drop 1 xs) (drop 2 xs)

--
Jedaï


_______________________________________________
Beginners mailing list
Beginners@haskell.org
http://mail.haskell.org/cgi-bin/mailman/listinfo/beginners




--
Beauty of style and harmony and grace and good rhythm depend on simplicity. - Plato