Safe Haskell | Safe |
---|
Aux
Description
This trusted module defines several auxiliary functions.
Documentation
update :: [a] -> Int -> a -> [a]
returns the list that's like update
xs i yxs
except that its i
th
(counting from 0
) element is y
. It raises an exception if i
isn't an
index into xs
.
strToInteger :: String -> Maybe Integer
returns strToInteger
xNothing
, if x
isn't a numeral;
oherwise, it returns Just
of the integer corresponding to x
.
Numerals are in base-10, and negative numerals have a leading
"-"
.
mapInd :: (Int -> a -> b) -> [a] -> [b]
returns
mapInd
f [x_0, ..., x_{n - 1}][f 0 x_0, ..., f (n - 1) x_{n - 1}]
.
tokens :: Eq a => (a -> Bool) -> [a] -> [[a]]
returns the unique list tokens
f xs[ys_1, ..., ys_n]
of nonempty
sublists of xs
such that there are nonempty lists zs_1
, ...
zs_{n - 1}
such that
-
xs = ys_1 ++ zs_1 ++ ... ++ ys_{n - 1} ++ zs_{n - 1} ++ ys_n
; and -
all f zs_1 && ... && all f zs_{n - 1} == True
.
allButLast :: [a] -> [a]
returns all elements of allButLast
xsxs
except the final one.
Raises an exception when xs
is empty.