
One thing that gets me about this solution.. as I was structuring mine I noticed that I was ending up with types like FilterWindow3 and functions like lowPass3. Inlining does eliminate them, but I wonder whether there is a good way to structure the computation generically so that it can be performed with windows of 5 as well as 3. The cons pattern matching here would get in the way, and in my original solution, the fact that I was using tuples got in the way also. Would Haskell's type system allow you to pass a function of arbitrary arity, discern its arity, use that information to construct the appropriate structure for iteration, and then apply it? Michael Tillmann Rendel wrote:
by inlining the definition above, this can be given as a four-liner now:
smooth n = (!! n) . iterate f where f ds = [(g y z + 2 * y + x) / 4.0 | x:y:z <- tails (head ds : ds)] g x [] = x g _ (x:_) = x
:-)
Tillmann
-- Now Playing: http://www.youtube.com/watch?v=SsnDdq4V8zg