You can list all the installed words in froth with the
WORDS word, or use froth.dictionary() from R.
The following is all the words referenced in the previous chapters.
-
<NUMBER> ( -- n ): pushes a number onto the stack -
emit ( n -- ): prints the top number of the stack, interpreting as ASCII -
cr ( -- ): prints a new line -
." xxx" ( -- ): printsxxxon the terminal. Note that"terminates the string. -
: xxx yyy ; ( -- ): defines a wordxxxcomprised of wordsyyy -
FORGET xxx ( -- ): removes the current wordxxx. Ifxxxhad a previous definition it reverts to that previous value, and otherwise the word is removed. -
+ (a b -- n): addsa+b -
* (a b -- n): multipliesa*b -
. (n -- ): pops the top element of stack and prints it -
clear ( x1 x2 ... -- ): removes all elements of the stack -
reset ( -- ): resetfrothto defaults (wipe all user definitions, reinitialize all built-in definitions, reset all stacks) -
/ ( a b -- n ): division (5 2 / => 2.5) -
%/% ( a b -- n): integer division (5 2 %/% => 2) -
mod ( a b -- rem ): remainder when dividinga / b -
/mod ( a b -- rem quot ): integer dividesa %/% b, pushes the remainder and then the quotient -
^ ( a b -- n ): raisesa^b -
negate ( a -- n ): negatesa -
abs ( a -- n ): takes the absolute value ofa -
min ( a b -- min ): pushesmin(a,b) -
max ( a b -- max ): pushesmax(a,b) -
sqrt ( a -- root ): pushessqrt(a) -
SWAP ( a b -- b a ): swap top two stack elements -
DUP ( n -- n n ): duplicate the top stack element -
OVER ( a b -- a b a ): duplicate the second element to the top of the stack -
ROT ( a b c -- b c a ): rotate the third item to the top -
DROP ( n -- ): discard the top element of the stack -
.S ( -- ): print out the contents of the stack -
2SWAP ( a b c d -- c d a b ): swap the top two pairs -
2DUP ( a b -- a b a b ): duplicate the top pair -
2OVER ( p1 p2 -- p1 p2 p1 ): duplicate the second pair (p1) to the top -
2DROP ( a b -- ): discard the top pair -
>R ( n -- ): moves the value on the parameter stack to the return stack -
R> ( -- n ): moves the value on the return stack to the parameter stack -
R@ ( -- n ): copies the value on the return stack to the parameter stack -
1+ ( n1 -- n2 ): adds 1 -
1- ( n1 -- n2 ): subtracts 1 -
2+ ( n1 -- n2 ): adds 2 -
2- ( n1 -- n2 ): subtracts 2 -
2* ( n1 -- n2 ): multiplies by 2 -
2/ ( n1 -- n2 ): divides by 2 -
*/ ( a b c -- n ): pushes(a*b) / c -
*/mod ( a b c -- rem quot ): pushes the remainder and quotient of(a*b) %/% c -
if: if top of stack isTRUE, executes. Else jumps to the nextelseorthenblock. -
else: executes commands untilthenonly if the precedingifdid not execute. -
then: terminates aniforif...elseblock. -
\: signals to the interpreter that you’re making a newline without running commands -
=: are the top two elements equal? -
<: is the top element greater than the first? -
>: is the top element less than the first? -
<>: are the top two elements not equal? -
0=: is the top element zero? -
0<: is the top element greater than zero? -
0>: is the top element less than zero? -
<=: is top element greater than or equal to the second? -
>=: is top element less than or equal to the second? -
AND: pushTRUEif the top two elements are bothTRUE -
OR: pushTRUEif at least one of the top two elements areTRUE -
XOR: pushTRUEif exactly one of the top two elements isTRUE -
NOT: pushTRUEif the top element isFALSEand vice-versa -
?DUP: duplicate top value if it is nonzero -
ABORT": abort if top value true, print error message (terminated by") -
DO ( end start -- ): starts a definite loop fromstarttoend -
LOOP ( -- ): increments the loop counter by 1 -
+LOOP ( n -- ): increments the loop counter by n -
I ( -- n ): copies the current loop counter to the stack -
J ( -- n ): copies the enclosing loop’s counter to the stack -
K ( -- n ): copies the enclosing loop’s enclosing loop’s counter to the stack -
BEGIN ( -- ): starts an indefinite loop -
AGAIN ( -- ): returns toBEGIN -
WHILE ( flag -- ): ifflag, continue; else jump to afterREPEAT -
REPEAT ( -- ): returns toBEGINfollowingWHILE -
LEAVE ( -- ): leave the current loop immediately -
VARIABLE xxx: creates a variable namedxxx -
! ( n addr -- ): stores the valuenat addressaddr -
@ ( addr -- n ): copies the value ataddrto the stack -
? ( addr -- ): prints the value ofaddr -
+! ( n addr -- ): adds the valuento the value ataddr -
CONSTANT xxx (n -- ): creates a constant calledxxxthat storesn;xxxreturnsnwhen called -
ALLOT ( addr ncells -- ): allocatesncellscells ataddr -
CREATE xxx y1 , y2 , ... yn ,: creates an arrayxxxwith valuesy1, y2, ... yn -
CELLS ( n -- ): creates a memory address offset for arrays -
FILL ( addr ncells val -- ): fillsncellscells of memory beginning ataddrwithval -
ERASE ( addr ncells -- ): fillsncellscells of memory beginning ataddrwith 0 -
REALLOT ( addr ncells -- ): reallots array ataddrto have sizencells. -
EXTEND ( addr ncells -- ): extends the array ataddrbyncellscells -
LENGTH ( addr -- len ): pushes the length of the array ataddronto the stack -
LENGTH? ( addr -- ): prints the length of the array ataddr -
' xxx ( -- addr ): attempts to findxxxin the dictionary, and pushes an execution token forxxxto the stack if found -
EXECUTE ( xt -- ): executes an execution token on top of the stack -
['] xxx ( -- addr ): currently equivalent to'forfroth