express-1.0.6: Dynamically-typed expressions involving function application and variables.
Copyright(c) 2019-2021 Rudy Matela
License3-Clause BSD (see the file LICENSE)
MaintainerRudy Matela <rudy@matela.com.br>
Safe HaskellSafe-Inferred
LanguageHaskell2010

Data.Express.Utils.List

Description

Re-exports the Data.List module along with additional functions over lists.

Synopsis

Documentation

nubSort :: Ord a => [a] -> [a] Source #

O(n log n). Sorts and remove repetitions. Equivalent to nub . sort.

> nubSort [1,2,3]
[1,2,3]
> nubSort [3,2,1]
[1,2,3]
> nubSort [3,2,1,3,2,1]
[1,2,3]
> nubSort [3,3,1,1,2,2]
[1,2,3]

nubSortBy :: (a -> a -> Ordering) -> [a] -> [a] Source #

Like nubSort but allows providing a function to compare values.

isPermutationOf :: Ord a => [a] -> [a] -> Bool Source #

O(n log n). Checks that all elements of the first list are elements of the second.

isSubsetOf :: Ord a => [a] -> [a] -> Bool Source #

O(n log n). Checks that all elements of the first list are elements of the second.

isNub :: Ord a => [a] -> Bool Source #

O(n log n). Checks that all elements are unique. This function is a faster equivalent to the following:

isNub xs  =  nub xs == xs

Examples:

isNub []       =  True
isNub [1,2,3]  =  True
isNub [2,1,2]  =  False

lookupId :: Eq a => a -> [(a, a)] -> a Source #

O(n). Like lookup but returns the key itself if nothing is found.

> lookupId 5 [(1,2),(3,4)]
5
> lookupId 5 [(1,2),(3,4),(5,6)]
6

(+++) :: Ord a => [a] -> [a] -> [a] infixr 5 Source #

Merges two lists discarding repeated elements.

The argument lists need to be in order.

> [1,10,100] +++ [9,10,11]
[1,9,10,11,100]

module Data.List