Last active
August 29, 2015 14:05
-
-
Save WillSewell/d77a0e0eb08be9a1d241 to your computer and use it in GitHub Desktop.
A Haskell foldl that slides a "window" over the list
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-- f now takes a sliding sublist of values, rather than each value | |
-- n is the window size | |
winFold :: ([a] -> b -> b) -> b -> [a] -> Int -> b | |
winFold f acc n [] = acc | |
winFold f acc n xs = winFold f (f (take n xs) acc) (tail xs) n |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment