To make searching easy I've included a list of all functions below. Otherwise, when you look
for "map" using your browser, you'll not only find the definition but all its uses, too.
You can send remarks, updates, and corrections to afie@cs.uu.nl
11 feb 2001: announced on Haskell mailing list
15 feb 2001: added types of operators
applied to a predicate and a list, returns True
if any of the elements of the list satisfy the predicate, and False
otherwise. Similar to the function all.
given a predicate and a list, breaks the list into two lists
(returned as a tuple) at the point where the predicate is first satisfied.
If the predicate is never satisfied then the first element of the
resulting tuple is the entire list and the second element is the empty
list ([]).
applied to an integer in the range 0 -- 255, returns the
character whose ascii code is that integer. It is the converse of the
function ord. An error will result if chr is applied to
an integer outside the correct range.
applied to to values of the same type which have an
ordering defined on them, returns a value of type Ordering which
will be: EQ if the two values are equal; GT if the
first value is strictly greater than the second; and LT if the
first value is less than or equal to the second value.
definition:
compare x y
| x == y = EQ
| x < y = LT
| otherwise = GT
given a function which maps a value to a list, and
a list of elements of the same type as the value, applies the function to
the list and then concatenates the result (thus flattening the resulting list).
converts a digit character into the corresponding integer
value of the digit.
definition:
digitToInt :: Char -> Int
digitToInt c
| isDigit c = fromEnum c - fromEnum '0'
| c >= 'a' && c <= 'f' = fromEnum c - fromEnum 'a' + 10
| c >= 'A' && c <= 'F' = fromEnum c - fromEnum 'A' + 10
| otherwise = error "Char.digitToInt: not a digit"
applied to a number and a list, returns the list with
the specified number of elements removed from the front of the list. If the
list has less than the required number of elements then it returns [].
definition:
drop 0 xs = xs
drop _ [] = []
drop n (_:xs) | n>0 = drop (n-1) xs
drop _ _ = error "PreludeList.drop: negative argument"
usage:
Prelude> drop 3 [1..10]
[4, 5, 6, 7, 8, 9, 10]
Prelude> drop 4 "abc"
""
applied to a value and a list returns True if the
value is in the list and False otherwise. The elements of the
list must be of the same type as the value.
applied to a string creates an error value with an
associated message. Error values are equivalent to the undefined
value (undefined), any attempt to access the value causes the program
to terminate and print the string as a diagnostic.
returns all but the last element of its argument list.
The argument list must have at least one element. If init is
applied to an empty list an error occurs.
applied to a list of characters containing newlines,
returns a list of lists by breaking the original list into lines using
the newline character as a delimiter. The newline characters are
removed from the result.
definition:
lines [] = []
lines (x:xs)
= l : ls
where
(l, xs') = break (== '\n') (x:xs)
ls
| xs' == [] = []
| otherwise = lines (tail xs')
given a function, and a list of any type, returns a
list where each element is the result of applying the function to the
corresponding element in the input list.
applied to a value of an enumerated type returns the
predecessor (previous value in the enumeration) of its argument. If its
argument is the first value in an enumeration an error will occur.
takes a string as an argument and returns an I/O action as
a result. A side-effect of applying putStr is that it
causes its argument string to be printed to the screen.
definition:
defined internally.
usage:
Prelude> putStr "Hello World\nI'm here!"
Hello World
I'm here!
given a predicate and a list, splits the list into
two lists (returned as a tuple) such that elements in the first list are
taken from the head of the list while the predicate is satisfied, and
elements in the second list are the remaining elements from the list
once the predicate is not satisfied.
definition:
span p [] = ([],[])
span p xs@(x:xs')
| p x = (x:ys, zs)
| otherwise = ([],xs)
where (ys,zs) = span p xs'
given an integer (positive or zero) and a list, splits
the list into two lists (returned as a tuple) at the position corresponding to
the given integer.
If the integer is greater than the length of the list, it returns a tuple
containing the entire list as its first element and the empty list as its
second element.
applied to a value of an enumerated type returns the
successor (next value in the enumeration) of its argument. If its argument
is the last value in an enumeration an error will occur.
applied to an integer (positive or zero)
and a list, returns the specified
number of elements from the front of the list. If the list has less than the
required number of elements, take returns the entire list.
definition:
take 0 _ = []
take _ []= []
take n (x:xs)
| n > 0 = x : take (n-1) xs
take _ _ = error "PreludeList.take: negative argument"
usage:
Prelude> take 4 "goodbye"
"good"
Prelude> take 10 [1,2,3]
[1,2,3]
converts an uppercase alphabetic character to a lowercase
alphabetic character. If this function is applied to an argument which is not
uppercase the result will be the same as the argument unchanged.
definition:
toLower c
| isUpper c = toEnum (fromEnum c - fromEnum 'A' + fromEnum 'a')
| otherwise = c
converts a lowercase alphabetic character to an uppercase
alphabetic character. If this function is applied to an argument which is not
lowercase the result will be the same as the argument unchanged.
definition:
toUpper c
| isLower c = toEnum (fromEnum c - fromEnum 'a' + fromEnum 'A')
| otherwise = c
given a predicate, a unary function and a value,
it recursively re--applies the function to the value until the
predicate is satisfied. If the predicate is never satisfied until
will not terminate.
definition:
until p f x
| p x = x
| otheriwise = until p f (f x)
applied to two lists, returns a list of pairs which are
formed by tupling together corresponding elements of the given lists. If
the two lists are of different length, the length of the resulting list is
that of the shortest.
definition:
zip xs ys
= zipWith pair xs ys
where
pair x y = (x, y)
the valid subscripts for a list l are: 0 .. (length l) - 1.
Therefore,
negative subscripts are not allowed, nor are subsripts greater
than one less than the length of the list argument. Subscripts out of this
range will result in a program error.
raises its first argument to the power of its second
argument. The arguments must be in the Floating numerical type class,
and the result will also be in that class.
raises its first argument to the power of its second
argument. The first argument must be a member of the Num type class,
and the second argument must be a member of the Integral
type class. The result will be of the same type as the first argument.
raises its first argument to the power of its second
argument. The first argument must be a member of the Fractional
type class, and the second argument must be a member of the Integral
type class. The result will be of the same type as the first argument.
is True if its first argument is not equal
to its second argument, and False otherwise. Equality is defined by
the == operator. Both of its arguments must be in the Eq
type class.
is True if its first argument is equal
to its second argument, and False otherwise. Equality is defined by
the == operator. Both of its arguments must be in the Eq