Title | Haskell function library |
---|---|
Author | Celeste Prussiani |
Course | Mathematics for Software Engineering |
Institution | Edinburgh Napier University |
Pages | 1 |
File Size | 78.6 KB |
File Type | |
Total Downloads | 95 |
Total Views | 153 |
Haskell programming language function library...
filter :: (a -> Bool) -> [a] -> [a]
Takes in a function and a list to return a list.
e.g. ex2> filter (==1) [1,2,3,2,1] [1,1] e.g.2: ex2> filter (=='a') ''Ciaone friends'' "a" even :: Int -> Bool
Returns true if the Int is even.
e.g. ex2> even 2 True e.g.2: ex2> filter (even) [1..10] [2,4,6,8,10] odd :: Int -> Bool
Returns true if the Int is odd.
map :: (a->b) -> [a] -> [b]
Takes a function that transforms values of type a into values of type a and returns a list of things of type b. (Note: a and b aren't necessarily different types)
e.g.: ex2> map (>2) [1,2,3] [False,False,True] length :: [a] -> Int
Returns the number of elements in a list
head :: [a] -> a
Returns the first element of a list
last :: [a] -> a
Returns the last element of a list...