let odd x = x `mod` 2 == 1
let even x = x `mod` 2 == 0
filter odd [1..10]
filter even [1..10]
let myfilter x = x `mod` 4 == 0 && x `mod` 3 /= 0
filter myfilter [1..20]
Prelude> foldr (:) [] [1..]
[1,2,3,4,5,6,7,8,9,10,...
Prelude> foldl (>:) [] [1..]
-- ...
-- sum
sum = foldl' (+) 0
-- product
product = foldl' (*) 1
-- length
length = foldl' (\acc _ -> acc + 1) 0
-- map
map f = foldr (\x acc -> f x : acc) []
map f = foldr ((:) . f) []
-- (++)
[] ++ ys = ys
xs ++ [] = xs
(x:xs) ++ ys = x:xs ++ xy
-- reverse
reverse [] = []
reverse (x:xs) = reverse xs ++ [x]
-- take
take _ [] = []
take n (x:xs) | n <= 0 = []
| otherwise = x : take (n-1) xs
-- drop ("as" pattern)
drop _ [] = []
drop n xxs@(_:xs) | n <= 0 = xxs
| otherwise = drop (n-1) xs