Safe Haskell | None |
---|---|
Language | Haskell98 |
Functions that are counterparts of the generic
functions in Data.List
using NumericPrelude.Numeric type classes.
For input arguments we use the restrictive ToInteger
constraint,
although in principle RealRing
would be enough.
However we think that take 0.5 xs
is rather a bug than a feature,
thus we forbid fractional types.
On the other hand fractional types as result can be quite handy,
e.g. in average xs = sum xs / length xs
.
Synopsis
- (!!) :: C n => [a] -> n -> a
- lengthLeft :: C n => [a] -> n
- lengthRight :: C n => [a] -> n
- replicate :: C n => n -> a -> [a]
- take :: C n => n -> [a] -> [a]
- drop :: C n => n -> [a] -> [a]
- splitAt :: C n => n -> [a] -> ([a], [a])
- findIndex :: C n => (a -> Bool) -> [a] -> Maybe n
- elemIndex :: (C n, Eq a) => a -> [a] -> Maybe n
- findIndices :: C n => (a -> Bool) -> [a] -> [n]
- elemIndices :: (C n, Eq a) => a -> [a] -> [n]
Documentation
(!!) :: C n => [a] -> n -> a Source #
The index must be smaller than the length of the list, otherwise the result is undefined.
lengthLeft :: C n => [a] -> n Source #
Left associative length computation
that is appropriate for types like Integer
.
lengthRight :: C n => [a] -> n Source #
Right associative length computation
that is appropriate for types like Peano
number.
findIndices :: C n => (a -> Bool) -> [a] -> [n] Source #
elemIndices :: (C n, Eq a) => a -> [a] -> [n] Source #