Skinney/elm-deque/1.1.0

NOTE: the latest version is 1.2.0

Renamed to robinheghan/elm-deque. It is published under that name, and new versions come out there.

Versions published as Skinney/elm-deque still install under that name. 2 versions of 3 come from the new location (see their notes). 1 version could not be recovered and cannot be installed.

Rerouted (renamed, verified). The GitHub user or repository was renamed. The tag is still there, at the new name. The Lamdera package server serves a copy recovered from https://github.com/robinheghan/elm-deque.

What we checked: The repo moved to github.com/robinheghan/elm-deque. Rebuilt with git archive from commit 92fb6925dd6e of https://github.com/robinheghan/elm-deque (zip prefix Skinney-elm-deque-92fb692/, America/Los_Angeles times): the zip is byte-identical to the one package.elm-lang.org recorded, SHA-1 4bfb473171f4f859accba0a7317620853ff6ef59.

The Lamdera compiler uses this copy and prints a one-line notice saying so. elm itself fails to download this version.

Details · package.elm-lang.org's zip: https://github.com/Skinney/elm-deque/zipball/1.1.0/

Deque

A double ended queue (deque, pronounced 'deck')

Type

type Deque a

The deque datatype

Deque equality with (==) is unreliable (equivalent deques can have a different distribution of elements between the back and the front) and should not be used.

Construct

The empty deque

singleton : a -> Deque a

Create a deque consisting of a single element

pushFront : a -> Deque a -> Deque a

Adds an element to the front of the deque

pushBack : a -> Deque a -> Deque a

Adds an element as the last element of the deque

append : Deque a -> Deque a -> Deque a

Create a new deque containing all the elements of the provided deques. Order is preserved.

Deconstruct

popFront : Deque a -> ( Maybe a, Deque a )

Returns a tuple of the first element and the remaining elements of the deque. The first element of the tuple will be Nothing íf this is run on the empty deque.

popBack : Deque a -> ( Maybe a, Deque a )

Returns a tuple containing the last element and the remaining elements of the deque. The first element of the tuple will be Nothing if this function is run on the empty deque.

left : Int -> Deque a -> Deque a

Take n number of elements from the left

dropLeft : Int -> Deque a -> Deque a

Drop n number of elements from the left

dropRight : Int -> Deque a -> Deque a

Drop n number of elements from the right

Lists

fromList : List a -> Deque a

Converts a List to a deque.

toList : Deque a -> List a

Converts the deque to a List

Query

isEmpty : Deque a -> Bool

Check if the deque holds no elements

member : a -> Deque a -> Bool

Check if the provided element exists in this deque (using ==).

length : Deque a -> Int

Get the length of the deque

first : Deque a -> Maybe a

Get the first element of the deque

last : Deque a -> Maybe a

Get the last element of the deque

equals : Deque a -> Deque a -> Bool

Check if two deques contain the same elements

Transform

map : (a -> b) -> Deque a -> Deque b

Create a new deque where every element is the result of running fn on every element.

filter : (a -> Bool) -> Deque a -> Deque a

Create a new deque which only contains the elements where the provided fn returned True

filterMap : (a -> Maybe b) -> Deque a -> Deque b

Allows running both filter and map in the same operation. The provided function is run on every element and returns a Maybe. Only the Just values will be kept in the resulting deque

foldl : (a -> b -> b) -> b -> Deque a -> b

Fold over the elements of the deque starting from the front.

foldr : (a -> b -> b) -> b -> Deque a -> b

Fold over the elements of the deque starting from the back.

partition : (a -> Bool) -> Deque a -> ( Deque a, Deque a )

Returns a tuple of deques, where the first deque contains every element where the function returned True, while the second deque contains the other elements.