Append one list to another in constant time.
Prepend a single element in constant time.
Append a single element in constant time.
Map over a difference list, then flatten.
Fold over a difference list.
Get the first element of the list.
Map over a difference list.
Get the tail of the list.
Convert to a normal list.
List elimination of head and tail.
Difference lists: a data structure for
O(1)
append on lists. Based onData.DList
, a Haskell library by Don Stewart.A difference list is a function that given a list, returns the original contents of the difference list prepended at the given list.
This structure supports
O(1)
append and snoc operations on lists, making it very useful for append-heavy uses, such as logging and pretty printing.