BoundedList are just list with a set maximum size. If you've reached the max size and add more elements, then some will be dropped!
Create an empty BoundedList with a specific maxSize
(empty 4 |> tolist) == []Create a BoundedList from a given list and maximum size. If the given list doesn't respect the size constraint, elements from the begining of the list will be drop to fit in.
(fromList 2 [ 1, 2, 3, 4 ] |> toList) == [ 3, 4 ]take a List and adds it at the end of an existing BoundedList. If the resulting list is too large, elements from the top of the list are dropped until it fits
(appendEnd (fromList 2 [ 1, 2, 3 ]) [ 4, 5, 6 ] |> toList) == [ 5, 6 ]
(appendEnd (fromList 6 [ 1, 2, 3 ]) [ 4, 5, 6 ] |> toList) == [ 1, 2, 3, 4, 5, 6 ]
(appendEnd (fromList 4 [ 1, 2 ]) [ 3, 4, 5 ] |> toList) == [ 2, 3, 4, 5 ]take a List and adds it at the start of an existing BoundedList. If the resulting list is too large, elements from the end of the list are dropped until it fits.
(appendStart [ 1, 2, 3 ] (fromList 2 [ 4, 5, 6 ]) |> toList) == [ 1, 2 ]
(appendStart [ 1, 2, 3 ] (fromList 6 [ 4, 5, 6 ]) |> toList) == [ 1, 2, 3, 4, 5, 6 ]
(appendStart [ 1, 2, 3 ] (fromList 4 [ 4, 5 ]) |> toList) == [ 1, 2, 3, 4 ]extract the List part from a BoundedList
(empty 4 |> tolist) == []
(fromList 4 [ 1, 2 ] |> tolist) == [ 1, 2 ]
A list of
itemTypethat will have a maximum number of items within.The type is opaque so refer to the next section to see how to create a
BoundedList