difflist

Difference lists in Elixir

Install

In your mix.exs:

defp deps do
  [
    {:difflist, "~> 1.0.0"}
  ]
end

Then run mix deps.get.

Usage

The best place to read the documentation is in HexDocs or in iex (e.g. h DiffList.from_list).

This package exposes a DiffList module with the following functions:

Creating difference lists

DiffList.from_list/1

Creates a difference list from a regular list.

DiffList.empty/0

Creates an empty difference list.

DiffList.singleton/1

Creates a difference list of one element.

Using difference lists

DiffList.append/2

Appends a difference list to another difference list.

DiffList.cons/2

Prepends an item to a difference list.

DiffList.snoc/2

Appends an item to a difference list.

DiffList.head/1

Gets the first item of a difference list.

DiffList.tail/1

Gets the tail (a difference list of everything but the first item) of a difference list.

DiffList.concat/1

Concatenates a list of difference lists into one difference list.

Benchmark

A simple left-associated append benchmark is included. Run mix bench to run it.

License

MIT © Juan Soto