Boxes
Factor handbook » The language » Collections

Prev:Heaps
Next:Directed graph utilities


A box is a container which can either be empty or hold a single value.
box


Creating an empty box:
<box> ( -- box )


Storing a value and removing a value from a box:
>box ( value box -- )

box> ( box -- value )


Safely removing a value:
?box ( box -- value/f ? )


Testing if a box is full can be done by reading the occupied slot.