A list that can only contain unique elements
Create an empty `UniqueList
List.Unique.empty == List.Unique.fromList []Check if an Order is empty
Order.isEmpty Order.empty == TrueCreate a UniqueList from a List
Turn a UniqueList into a List
let
u =
[ 'u' ]
doubleU =
[ 'u', 'u' ]
in
u == (List.Unique.toList <| List.Unique.fromList doubleU)Get the length of a UniqueList
nobleGases = List.Unique.fromList
[ helium
, neon
, argon
, krypton
, xenon
, radon
]
List.Unique.length nobleGases == 6Reverse a UniqueList
bestCoffeeDrinks ==
List.Unique.fromList
[ cortado
, latte
, coldbrew
, coffee
, mocha
]
worstCoffeeDrinks : UniqueList Coffee
worstCoffeeDrinks =
List.Unique.reverse bestCoffeeDrinksCheck if something is in a UniqueList
List.Unique.member "Grover Cleveland" usPresidents == TrueRemove an element from a `UniqueList
Add an element to the beginning of a UniqueList
Add an element to a UniqueList before another element
addBefore `c` `b` (List.Unique.fromList [ `a`, `c`, `d` ])
== List.Unique.fromList [ `a`, `b`, `c`, `d` ]Add an element to a UniqueList before another element
addAfter `b` `c` (List.Unique.fromList [ `a`, `b`, `d` ])
== List.Unique.fromList [ `a`, `b`, `c`, `d` ]Check if an element is before another, if it is in the UniqueList at all.
germanStates = List.Unique.fromList [ "Bavaria", "Brandenberg" ]
("Bavaria" |> List.Unique.isBefore "Brandenberg") germanStates == Just True
("Bavaria" |> List.Unique.isBefore "New York City") germanStates == NothingCheck if an element is after another, if it is in the UniqueList at all.
Check is an element is the first in a UniqueList
If you just need to filter out duplicates, but dont want to use th UniqueList type, use this function. Its just like the unique function in elm-community/list-extra, except for the fact that List.Extra.unique only works on List comparable.
filterDuplicates [ True, True ] == [ True ]
filterDuplicates [ 1, 1, 2, 3, 5 ] == [ 1, 2, 3, 5 ]
An arrangement of things in an order. An
UniqueListis kind of like aList, except there cant be duplicate elements. And, its kind of like aSet, except anUniqueLists elements go from first to last.