Reference · Stack

Stack

37 words. Sorted alphabetically.

-ROT
  • ( a:any b:any c:any -- c:any a:any b:any )

Rotate the top three items down (Forth-familiar alias for ROTD). (a b c -- c a b).

?DUP
  • ( x:any -- x:any )

Duplicate TOS iff it is truthy — Double/Integer non-zero, Boolean true, or any non-scalar. Zero-value scalars pass through unchanged.

.S
  • ()

Print the stack contents to the debug sink.

BI
  • ( any any any )

Apply two Progns to the same value, in order. ( x p q -- ..p(x) ..q(x) ).

BI@
  • ( any any any )

Apply one Progn to two different values. ( x y q -- ..q(x) ..q(y) ).

BI*
  • ( any any any )

Apply two Progns to two different values, pairwise. ( x y p q -- ..p(x) ..q(y) ).

CLEAR
  • ()

Clear the entire stack.

DEPTH
  • ( -- depth:double )

Push the current stack depth.

DIP
  • ( any any )

Save TOS, run the Progn (NOS) on what's below, then restore the saved value on top. ( x q -- x ) where q's effect is on values under x.

DROP
  • ( a:any )

Discard TOS.

DROP2
  • ( a:any b:any )

Drop the top two items (equivalent to DROP DROP).

DROPn
  • ( n:integer )

Drop the top n items. n is on TOS.

DUP
  • ( a:any -- a:any a:any )

Duplicate TOS.

DUP2
  • ( a:any b:any -- a:any b:any a:any b:any )

Duplicate the top two items (equivalent to OVER OVER).

DUPn
  • ( n:integer )

Duplicate the top n items. n is on TOS.

KEEP
  • ( any any )

Run the Progn with TOS on the stack (consuming it), then restore a copy of the original TOS on top. ( x q -- ..y x ).

NIP
  • ( a:any b:any -- b:any )

Remove NOS (second-from-top). Equivalent to SWAP DROP.

NIPn
  • ( n:integer )

Remove the item at depth n. n is on TOS.

OVER
  • ( a:any b:any -- a:any b:any a:any )

Copy NOS (second item) to TOS.

OVER2
  • ( a:any b:any c:any d:any -- a:any b:any c:any d:any a:any b:any )

Copy the pair at levels 3,4 to the top. (a b c d -- a b c d a b).

PICK
  • ( n:integer -- item:any )

Copy the item at depth n to TOS. n is on TOS.

POP-FRAME
  • ( -- stack:stack )

PUSH-FRAME
  • ( stack:stack )

REVERSE
  • ()

Reverse the entire stack.

REVERSEn
  • ( n:integer )

Reverse the top n items. n is on TOS.

ROLLD
  • ()

Roll the whole stack down: bottom item becomes TOS.

ROLLDn
  • ( n:integer )

Roll the top n items down. n is on TOS.

ROLLU
  • ()

Roll the whole stack up: TOS moves to the bottom.

ROLLUn
  • ( n:integer )

Roll the top n items up. n is on TOS.

ROTD
  • ( a:any b:any c:any -- c:any a:any b:any )

Rotate the top three items down.

ROTU
  • ( a:any b:any c:any -- b:any c:any a:any )

Rotate the top three items up.

SWAP
  • ( a:any b:any -- b:any a:any )

Exchange the top two items.

SWAP2
  • ( a:any b:any c:any d:any -- c:any d:any a:any b:any )

Swap the top two pairs. (a b c d -- c d a b).

SWAPn
  • ( n:integer )

Exchange TOS with the item at level n. Only those two items move — items between them stay put (distinct from ROLLUn/ROLLDn which rotate the whole window). n=1 is a no-op; n=2 is equivalent to SWAP. n is on TOS.

TRI
  • ( any any any )

Apply three Progns to the same value, in order. ( x p q r -- ..p(x) ..q(x) ..r(x) ).

TUCK
  • ( a:any b:any -- b:any a:any b:any )

Tuck TOS under NOS. Fixed-2 case of TUCKn — equivalent to SWAP OVER.

TUCKn
  • ( n:integer )

Tuck TOS under the n-th item. n is on TOS.

Contact

Send us a message — we'll reply by email.