fromList

Converts a normal list to a NonEmpty stream. Raises an error if given an empty list.
The fromList function constructs the structure l from the given list of Item l
Create a map from a list of key/value pairs.
fromList [] == empty
fromList [(5,"a"), (3,"b"), (5, "c")] == fromList [(5,"c"), (3,"b")]
fromList [(5,"c"), (3,"b"), (5, "a")] == fromList [(5,"a"), (3,"b")]
Create a set from a list of integers.
Build a map from a list of key/value pairs. See also fromAscList. If the list contains more than one value for the same key, the last value for the key is retained. If the keys are in non-decreasing order, this function takes <math> time.
fromList [] == empty
fromList [(5,"a"), (3,"b"), (5, "c")] == fromList [(5,"c"), (3,"b")]
fromList [(5,"c"), (3,"b"), (5, "a")] == fromList [(5,"a"), (3,"b")]
Create a sequence from a finite list of elements. There is a function toList in the opposite direction for all instances of the Foldable class, including Seq.
Create a set from a list of elements. If the elements are in non-decreasing order, this function takes <math> time.
Construct a map with the supplied mappings. If the list contains duplicate mappings, the later mappings take precedence.
>>> fromList [("a", 'x'), ("a", 'y')]
fromList [("a",'y')]
Construct a map with the supplied mappings. If the list contains duplicate mappings, the later mappings take precedence.
Construct a set from a list of elements.
O(n) amortized. Construct a Deque from a list of values.
>>> fromList [1,2]
BD 1 [1] 1 [2]
Build an index out of a bunch of packages. If there are duplicates by UnitId then later ones mask earlier ones.
Store the list in a flattened memory representation, avoiding the memory overhead of a linked list. The size n needs to be smaller or equal to the length of the list. If it is smaller than the length of the list, overflowing elements are discarded. It is undefined behaviour to set n to be bigger than the length of the list.
Turn a list into a Stream, by yielding each element in turn.
Create a map from a list of key/value pairs.
fromList [] == empty
fromList [(5,"a"), (3,"b"), (5, "c")] == fromList [(5,"c"), (3,"b")]
fromList [(5,"c"), (3,"b"), (5, "a")] == fromList [(5,"a"), (3,"b")]
Create a set from a list of integers.
fromList xs is a DList representing the list xs. fromList obeys the laws:
toList . fromList = id
fromList . toList = id
This function is implemented with ++. Repeated uses of fromList are just as inefficient as repeated uses of ++. If you find yourself doing some form of the following (possibly indirectly), you may not be taking advantage of the DList representation and library:
fromList . f . toList
More likely, you will convert from a list, perform some operation on the DList, and convert back to a list:
toList . g . fromList
fromList xs is a DNonEmpty representing the list xs. If xs is empty, an error is raised. fromList obeys the law:
fromList xs = fromNonEmpty (fromList xs)
Sample a random value from a weighted list. The list must be non-empty and the total weight must be non-zero.