:: (a -> Bool) -> [a] -> [a] -is:exact -is:exact -is:exact package:daml-stdlib -is:exact
A version of `dropWhile` operating from the end.
A version of `takeWhile` operating from the end.
Take elements from a list while the predicate holds.
Drop elements from a list while the predicate holds.
Filters the list using the function: keep only the elements where the predicate holds.
Sort a list by comparing the results of a key function applied to
each element. `sortOn f` is equivalent to `sortBy (comparing f)`,
but has the performance advantage of only evaluating `f` once for
each element in the input list. This is sometimes called the
decorate-sort-undecorate paradigm.
Elements are arranged from from lowest to highest, keeping
duplicates in the order they appeared in the input.
A version of `dedup` where deduplication is done
after applyng function. Example use: `dedupOn (.employeeNo) employees`
A version of `dedup` where deduplication is done
after applying the given function. Example use: `dedupOn (.employeeNo) employees`.
`dedupOn` is stable so the elements in the output are ordered
by their first occurrence in the input. If you do not need
stability, consider using `dedupOnSort` which is more efficient.
```
>>> dedupOn fst [(3, "a"), (1, "b"), (1, "c"), (3, "d")]
[(3, "a"), (1, "b")]
```
`dedupOnSort` is a more efficient variant of `dedupOn`
that does not preserve the order of the input elements.
Instead the output will be sorted on the values returned by the function.
For duplicates, the first element in the list will be included in the output.
```
>>> dedupOnSort fst [(3, "a"), (1, "b"), (1, "c"), (3, "d")]
[(1, "b"), (3, "a")]
```
`sortOn f` is a version of sort that allows sorting
on the result of the given function.
`sortOn` is stable so elements that map to the same sort key
will be ordered by their position in the input.
```
>>> sortOn fst [(3, "a"), (1, "b"), (3, "c"), (2, "d")]
[(1, "b"), (2, "d"), (3, "a"), (3, "c")]
```