An open API service indexing awesome lists of open source software.

https://github.com/dwayne/elm-stack

A stack.
https://github.com/dwayne/elm-stack

elm stack

Last synced: 10 months ago
JSON representation

A stack.

Awesome Lists containing this project

README

          

# elm-stack

A stack.

## An example

```elm
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

```elm
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
```