On Sat, Mar 6, 2010 at 9:59 PM, Elko Tchernev <[email protected]> wrote:

>
> This way, the parameter will be dropped, not your computed Fib value, and it
> will work.

yes, that works. Thank you.

>
> In general, CASE is not a very useful or used construct in Forth; this is
> not C. The less you use it, the better.
>

I see. How would you not use CASE, as I have done below:

: 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 +
  SWAP ENDCASE ;


Reply via email to