Go to the first, previous, next, last section, table of contents.


Recursive functions

Forth has traditionally not handled recursion nicely, functions being disallowed from calling themselves naturally.

Muq MUF allows this sort of recursion quite naturally. Here is the venerable factorial function:

Stack:
: fact { $ -> $ } -> i   i 1 = if  i  else  i 1- fact i *  fi ;
Stack:
3 fact
Stack: 6

Note: This example also doesn't compile on version -1.0.0. Ick.


Go to the first, previous, next, last section, table of contents.