Created
June 7, 2016 17:04
-
-
Save taojang/90122c3033b0fd4bd22deae752ef2135 to your computer and use it in GitHub Desktop.
Some freaky point free stuff of chapter 10 of the haskell book
This file contains hidden or 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 Chapter10 where | |
| -- from Mark & Amr | |
| myOr :: [Bool] -> Bool | |
| myOr = foldr (||) False | |
| myAny :: (a -> Bool) -> [a] -> Bool | |
| myAny = (myOr .) . map | |
| myReverse :: [a] -> [a] | |
| myReverse = foldl (flip (:)) [] | |
| myMap :: (a -> b) -> [a] -> [b] | |
| myMap f = foldr ((:) . f) [] | |
| 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
Btw, I have found a point-free version for
myAnythat uses foldr.