dwayne/elm-stack

A stack


Keywords
elm, stack
License
BSD-3-Clause
Install
elm-package install dwayne/elm-stack 1.0.0

Documentation

elm-stack

A stack.

An example

import Stack as S

S.isEmpty S.empty == True

S.push 2 (S.push 1 S.empty) == S.fromList [ 2, 1 ]

S.top (S.fromList [ 2, 1 ]) == Just 2

S.pop (S.fromList [ 3, 2, 1 ]) == Just ( 3, S.fromList [ 2, 1 ])

S.toList (S.fromList [ 4, 3, 2, 1 ]) == [ 4, 3, 2, 1 ]

Public API

type Stack a

-- Construct

empty : Stack a
fromList : List a -> Stack a

-- Query

isEmpty : Stack a -> Bool
top : Stack a -> Maybe a

-- Modify

push : a -> Stack a -> Stack a
pop : Stack a -> Maybe ( a, Stack a )

-- Convert

toList : Stack a -> List a