> -----Original Message-----
> From: [email protected] [mailto:gforth-
> [email protected]] On Behalf Of Terrence Brannon
> But I would like to know why mine does not work:
> 
> : fib { n -- fibn }
>   assert( n 0>= )
>   n CASE
>     0 OF 0 ENDOF
>     1 OF 1 ENDOF
>     2 OF 1 ENDOF
>     ( otherwise ) n 1 - recurse n 2 - recurse +
>   ENDCASE ;

Remember that n is left on the stack after the last ENDOF, so you end up
putting it on again.

Not sure why you want 2 recurse's either or the other n 2 -.

I can't follow the logic, but then the people in that shootout are much
better at it than I am. ;)

DaR






Reply via email to