Created
November 29, 2018 13:29
-
-
Save deciduously/8b2babeb07782c046aa0dab9f1392634 to your computer and use it in GitHub Desktop.
Some library functions implemented in terms of foldr
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
module StdFolds where | |
myOr :: [Bool] -> Bool | |
myOr = foldr (||) False | |
myAny :: (a -> Bool) -> [a] -> Bool | |
myAny = flip foldr False . ((||) .) | |
myElem :: Eq a => a -> [a] -> Bool | |
myElem = myAny.(==) | |
myMap :: (a -> b) -> [a] -> [b] | |
myMap = flip foldr [] . ((:) .) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment