Created
May 27, 2018 22:24
-
-
Save dmitryshelomanov/ed78cc61561e02c7394eaa8c06b74c50 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
import Prelude hiding (map, filter) | |
map :: (a -> b) -> [a] -> [b] | |
map predicate list = | |
case list of | |
[] -> [] | |
(x:xs) -> predicate x : map predicate xs | |
map' predicate = map predicate | |
filter :: (a -> Bool) -> [a] -> [a] | |
filter predicate list = | |
case list of | |
[] -> [] | |
(x:xs) -> | |
if (predicate x) | |
then x : filter predicate xs | |
else filter predicate xs | |
filter' predicate = filter predicate | |
every :: (a -> Bool) -> [a] -> Bool | |
every predicate list = | |
case list of | |
[] -> True | |
(x:xs) -> | |
if (predicate x) | |
then every predicate xs | |
else False | |
every' predicate = every predicate | |
some :: (a -> Bool) -> [a] -> Bool | |
some predicate list = | |
case list of | |
[] -> False | |
(x:xs) -> | |
if (predicate x) | |
then True | |
else False | |
some' predicate = some predicate | |
main :: IO () | |
main = | |
. some' (\x -> x > 5) | |
. filter' (\x -> x > 5) | |
. map' (\x -> x * 10) $ list | |
where | |
list = [1, 2, 4 ,1, 3, 6, 3, 7, 8, 6, 0] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment