A list that can only contain unique elements
Create a UniqueList from a List
Turn a UniqueList into a List
[ 1 ] == (List.Unique.toList << List.Unique.fromList) [ 1, 1 ]Create an empty UniqueList
List.Unique.empty == List.Unique.fromList []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 == TrueAdd 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` ]Remove an element from a UniqueList
Check if an Order is empty
Order.isEmpty Order.empty == TrueCheck 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
("Brandenburg" |> List.Unique.isBefore "Bavaria") germanStates == Just False
("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.