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.
- Host: GitHub
- URL: https://github.com/dwayne/elm-stack
- Owner: dwayne
- License: bsd-3-clause
- Created: 2025-08-24T13:36:08.000Z (10 months ago)
- Default Branch: master
- Last Pushed: 2025-08-25T11:19:12.000Z (10 months ago)
- Last Synced: 2025-08-25T15:08:17.485Z (10 months ago)
- Topics: elm, stack
- Language: Elm
- Homepage: https://package.elm-lang.org/packages/dwayne/elm-stack/latest/
- Size: 51.8 KB
- Stars: 0
- Watchers: 0
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
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
```