mhoare/elm-stack/1.0.0

NOTE: this package is not compatible with Elm 0.19.1

Stack

This library implements a stack data structure in Elm, allowing you to worry more about your business logic and less about implementing common adts.

Definition

type alias Stack a =
{ data : Array a
, top : Int
, default : a
}
    The Stack type uses an array to represent the stack.

Common Helpers

initialise : a -> Int -> Stack a
    Initialises a stack given an initialisation value and a stack size.
pop : Stack (Maybe a) -> ( Maybe a, Stack (Maybe a) )
    Removes the item at the top of the stack and returns it as the first item of a tuple.
push : a -> Stack (Maybe a) -> Stack (Maybe a)
    Pushes an item onto the stack and returns the new stack. The item must be of the same type as the stack.