You are on page 1of 3

Num Fx

odd a : checks if number is odd


compare a b : LT if a < b ; EQ if a =b; GT if a > b
signum Int : Returns sign of Input
iterate f x : Produces an infinite list which applies f an increasing number
of times to x
repeat _ :Creates an infinite list of the argument
List Fx
head [_] : returns first element in list
[a] -> a
tail [_] : returns all but the first element in list
[a] -> [a]
last [_] : returns the last element of a list
[a] -> a
reverse [_] :returns a reversed list
[a] -> [a]
init [_] : returns all but the last element of a list
[a] -> a
take Num [_] : take returns the first n elements in list
Int -> [a] -> [a]
drop Num [_] : returns all but the first n elements in list
Int -> [a] -> [a]
splitAt Int [_] : returns a pair of input lists, split at given index
Int -> [a] -> ([a], [a])
takeWhile predicate [_] : returns elements from beginning, stops when False
is returned
(a -> Bool) -> [a] -> [a]
break predicate [_] : returns a pair of input lists, split where predicate s
ucceeds
Imagine that break is the filter for failures, only fa
ilures pass
(a -> Bool) -> [a] -> ([a], [a])
dropWhile predicate [_] : drops elements from beginning, stops when False is
returned
(a -> Bool) -> [a] -> [a]
span predicate [_] : returns a pair of input lists, split where predicate fa
ils
Imagine that span is a metal detector scanning people,
if false is returned
the flow is stopped.
(a -> Bool) -> [a] -> ([a], [a])
replicate Int _ : returns a fixed length repeating list of its argument
Int -> a -> [a]
null [_] : Returns Bool depending on whether list is empty

[a] -> Bool


reverse [_] : Returns elements in a list in reverse order
[a] -> [a]
[_] ++ [_] : Concatenate two lists
[a] -> [a] -> [a]
concat [[_]] : Concatenates a list of lists of the same type into one list,
or removes one layer
of nest
[[a]] -> [a]
a : [_] : add element a to list. This order must be kept
sum [Num] : Returns the summation of all numbers in list
Num a => [a] -> a
lines "String" : Splits up a text string on line boundaries like \n \r
String -> [String]
unlines [String] : Concatenates a list of strings, adding a newline to the e
nd of each
[String] -> String
words "String" : split an input string on any whitespace
String -> [String]
unwords [String] -> joins a list of words, using a single space to seperate
them
[String] -> String
elem _ [_] : Returns if a value is present in the given list.
Eq a => a ->[a]-> Bool
notElem _ [_] : returns if a value is not present in given list
Eq a => a -> [a] -> Bool
filter predicate [_] : returns every element in given list where element suc
ceeds
(a -> Bool) -> [a] -> [a]
length [_] : returns the length of an input list
[a] -> Int
and [Bool] : && function over a list of boolean values
[Bool] -> Bool
or [Bool] : || function over a list of boolean values
[Bool] -> Bool
all predicate [_] : returns True if predicate returns True on every element
of list
(a -> Bool) -> [a] -> Bool
any predicate [_] : returns True if predicate returns True on any element of
list
(a -> Bool) -> [a] -> Bool
zip [_] [_] : `zips` up two lists in pairs. The result list is the length of

the shorter list


To zip more than 2 lists, call zip3 ,zip4, etc
[a] -> [b] -> [(a,b)]
zipWith function [_] [_] : applies function to each zip pair, generating a s
ingle list
To zipWith more than 2 lists, call zipWith3 , zip
With4 etc
(a -> b -> c) -> [a] -> [b] -> [c]
map function [_] : Applies a function to each element of list and returns th
e resultant list
(a -> b) -> [a] -> [b]
filter predicate [_] : Applies predicate to every element in list and retur
n a list where True
(a -> Bool) -> [a] -> [a]
lookup key [(_,_),(_,_),..] : looks for a signature key in the first element
of each pair, returns
a Just value if found, otherwise Nothing
Eq a => a -> [(a,b)] -> Maybe b
<Data.List> isPrefixOf [_] [_] : Returns Bool depending on whether first list
is prefix of other
Eq a => [a] -> [a] -> Bool
<Data.List> isSuffixOf [_] [_] : Returns Bool depending on whether first lis
t is suffix of other
Eq a => [a] -> [a] -> Bool
<Data.List> isInfixOf [_] [_] : Returns Bool depending on whether first list
matches anywhere
Eq a => [a] -> [a] -> Bool
<Data.List> tails [Char] : Returns all the tails of a list. So tails "banana
" = "banana" "anana"
"ana" "na" "a" ""
[a] -> [[a]]
<Data.List> delete target [_] : Deletes the first occurance of target in a l
ist.
Eq a => a -> [a] -> [a]
<Data.List> elemIndex element [_]: Returns the index of a first target eleme
nt found
Eq a => a -> [a] - Maybe Int
Tuple Fx
fst (_,_) : Returns first element in a pair tuple
snd (_,_) : Returns second element in a pair tuple
Error Fx
error "str" : aborts evaluation of expression and prints error msg

You might also like