forthkit
forthkit copied to clipboard
recurse doesn't work, here is my fix
Using the following factorial definition as a test:
: fac dup 1 = if drop 1 else dup 1- recurse * then ;
"5 fac ." returns 20 as a result which is incorrect.
Redefining recurse (and fac again which depends on it) as :
: recurse last @ code> @ , ; immediate
: fac dup 1 = if drop 1 else dup 1- recurse * then ;
"5 fac ." returns 120 as a result, which is correct.