Skip to the content.

stack.fs (lib)

The stack.fs library contains words define and use stacks.

Usage

Define a new stack with STACK and clear it before use.

require stack.fs

10 STACK my-stack

: main
  my-stack clear ;

Word Index

clear ( a-addr – )

Clears the stack.

empty? ( a-addr – f )

Returns whether the stack is empty.

peek ( a-addr – x )

Returns the top value from the stack, without removing it.

pop ( a-addr – x )

Pops the top value from the stack.

push ( x a-addr – )

Pushes a value on the stack.

size ( a-addr – u )

Returns the number of values on the stack.

STACK ( u β€œname” – )

Create a new stack for at most u values.