Haskell/Solutions/More on functions
< Haskell | Solutions
Operators
| Exercises |
|---|
|
1.
- Substitute
fto getmap (\ x -> x * 2 + 3) xs - Substitute
fto getfoldr (\ x y -> read x + y) 1 xs
2.
(4+)- Becomes
(\ x -> 4 + x) - Has type
Num a => a -> a
- Becomes
(1 `elem`)- Becomes
(\ x -> 1 `elem` x) - Alternately written as
(\ x -> elem 1 x) - Has type
Num a :: a -> Bool- Note: The full type is
(Foldable t, Eq a, Num a) => t a -> Boolbut this has not been covered yet.
- Note: The full type is
- Becomes
(`notElem` "abc")- Becomes
(\ x -> x `notElem` "abc") - Alternately written as
(\ x -> notElem x "abc") - Has type
Char -> Bool
- Becomes