Documentation Index
Fetch the complete documentation index at: https://docs.canton.network/llms.txt
Use this file to discover all available pages before exploring further.
DA.List
ListModule Snapshot
Lifecycle
Stable.
Notices
Status:
active
Introduced in: 3.4.9
Removed in: -
Warnings: 0
Deprecations: 0
Deprecated since: -Functions
sort
sort function implements a stable sorting algorithm. It is
a special case of sortBy, which allows the programmer to supply
their own comparison function.
Elements are arranged from lowest to highest, keeping duplicates in
the order they appeared in the input (a stable sort).
sortBy
sortBy function is the non-overloaded version of sort.
minimumBy
minimumBy f xs returns the first element x of xs for which f x y
is either LT or EQ for all other y in xs. xs must be non-empty.
maximumBy
maximumBy f xs returns the first element x of xs for which f x y
is either GT or EQ for all other y in xs. xs must be non-empty.
sortOn
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.
minimumOn
minimumOn f xs returns the first element x of xs for which f x
is smaller than or equal to any other f y for y in xs. xs must be
non-empty.
maximumOn
maximumOn f xs returns the first element x of xs for which f x
is greater than or equal to any other f y for y in xs. xs must be
non-empty.
mergeBy
combinePairs
foldBalanced1
foldl1 or foldr1.
group
groupBy
groupOn
dedup
dedup l removes duplicate elements from a list. In particular,
it keeps only the first occurrence of each element. It is a
special case of dedupBy, which allows the programmer to supply
their own equality test.
dedup is called nub in Haskell.
dedupBy
dedup with a custom predicate.
dedupOn
dedup where deduplication is done
after applyng function. Example use: dedupOn (.employeeNo) employees
dedupSort
dedupSort function sorts and removes duplicate elements from a
list. In particular, it keeps only the first occurrence of each
element.
dedupSortBy
dedupSort with a custom predicate.
unique
uniqueBy
unique with a custom predicate.
uniqueOn
assert $ uniqueOn (.employeeNo) employees
replace
dropPrefix
dropSuffix
stripPrefix
stripPrefix function drops the given prefix from a list.
It returns None if the list did not start with the prefix
given, or Some the list after the prefix, if it does.
stripSuffix
stripInfix
None
if the search string is not found.
isPrefixOf
isPrefixOf function takes two lists and returns True if
and only if the first is a prefix of the second.
isSuffixOf
isSuffixOf function takes two lists and returns True if
and only if the first list is a suffix of the second.
isInfixOf
isInfixOf function takes two lists and returns True if
and only if the first list is contained anywhere within the second.
mapAccumL
mapAccumL function combines the behaviours of map and
foldl; it applies a function to each element of a list, passing
an accumulating parameter from left to right, and returning a final
value of this accumulator together with the new list.
mapWithIndex
map, mapWithIndex takes a mapping
function that also depends on the element’s index, and applies it to every
element in the sequence.
inits
inits function returns all initial segments of the argument,
shortest first.
intersperse
intersperse function takes an element and a list and
“intersperses” that element between the elements of the list.
intercalate
intercalate inserts the list xs in between the lists in xss
and concatenates the result.
tails
tails function returns all final segments of the argument,
longest first.
dropWhileEnd
dropWhile operating from the end.
takeWhileEnd
takeWhile operating from the end.
transpose
transpose function transposes the rows and columns of its
argument.
breakEnd
breakOn
needle in haystack.
The first element of the returned tuple is the prefix of haystack
before needle is matched. The second is the remainder of
haystack, starting with the match. If you want the remainder
without the match, use stripInfix.
breakOnEnd
breakOn, but searches from the end of the
string.
The first element of the returned tuple is the prefix of haystack
up to and including the last match of needle. The second is the
remainder of haystack, following the match.
linesBy
lines with a custom test. In particular, if there
is a trailing separator it will be discarded.
wordsBy
words with a custom test. In particular, adjacent
separators are discarded, as are leading or trailing separators.
head
tail
last
init
foldl1
foldr1
repeatedly
chunksOf
delete
delete x removes the first occurrence of x from its list argument.
For example,
deleteBy
\\
\\ function is list difference (non-associative).
In the result of xs \\ ys, the first occurrence of each element of
ys in turn (if any) has been removed from xs. Thus
singleton
!!
xs !! 2 returns the third element in xs.
Raises an error if the index is not suitable for the given list.
The function has complexity O(n) where n is the index given,
unlike in languages such as Java where array indexing is O(1).
elemIndex
None if not found.
findIndex
None if not found.