Created
May 5, 2011 06:18
-
-
Save jutememo/956626 to your computer and use it in GitHub Desktop.
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
foldr3' _ z [] p k _ = k z | |
foldr3' f'cps z (x:xs) p k k' | |
| p x = k' x | |
| otherwise = f'cps x (foldr3' f'cps z xs p k k') $ \y -> k y | |
main = do print $ foldr3' (\x y k -> k $ x ++ y) [] | |
[[1,2],[3,4],[5,6]] (== []) id id | |
print $ foldr3' (\x y k -> k $ x ++ y) [] | |
[[1,2],[3,4],[],[5,6]] (== []) id id |
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
foldr3' _ z [] p k _ = k z | |
foldr3' f_cps z (x:xs) p k k' | |
| p x = k' x | |
| otherwise = f_cps x (foldr3' f_cps z xs p k k') $ \y -> k y | |
main = do print $ foldr3' (\x y k -> k $ x ++ y) [] | |
[[1,2],[3,4],[5,6]] (== []) id id | |
print $ foldr3' (\x y k -> k $ x ++ y) [] | |
[[1,2],[3,4],[],[5,6]] (== []) id id |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment