Created
February 2, 2016 09:09
-
-
Save kseo/7275a3d692a335dd5851 to your computer and use it in GitHub Desktop.
Short-Circuiting Fold
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
import Data.Maybe | |
ssfold :: (a -> Bool) -> (a -> b -> a) -> a -> [b] -> a | |
ssfold p f a0 xs = foldr (\x xs a -> if p a then a else xs (f a x)) id xs a0 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment