Denys Duchier
This module provides a functional implementation of stacks
The module exports the following constructors:
{Stack.new ?S}
S
, currently
empty
{Stack.newFromList +L ?S}
S
initialized
with the elements of list L
Each functional stack instance S
has the following features:
{S.get ?V}
V
available from S
,
or raises exception empty
if none
{S.put +V}
V
onto the stack
{S.getPut ?Old +New}
Old
available from S
and pushes the value New
. If S
was empty, New
is Old
and S
is still empty
{S.top ?V}
V
available on top of S
without actually removing it
{S.toList ?L}
L
of all values in S
{S.toListKill ?L}
L
of all values in S
and makes S
unusable until a subsequent {S.reset}
.
{S.isEmpty ?B}
S
is empty
{S.reset}
S
's content and resets it to an empty stack
{S.clone ?S2}
S2
which is
a clone of S