Safe Haskell | None |
---|

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`

.

- (!!) :: 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 -> aSource

The index must be smaller than the length of the list, otherwise the result is undefined.

lengthLeft :: C n => [a] -> nSource

Left associative length computation
that is appropriate for types like `Integer`

.

lengthRight :: C n => [a] -> nSource

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