[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [gforth] naive fibonacci
From: |
Terrence Brannon |
Subject: |
Re: [gforth] naive fibonacci |
Date: |
Sun, 7 Mar 2010 05:36:12 -0500 |
On Sat, Mar 6, 2010 at 9:59 PM, Elko Tchernev <address@hidden> 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 ;
- [gforth] naive fibonacci, Terrence Brannon, 2010/03/06
- RE: [gforth] naive fibonacci, Dennis Ruffer, 2010/03/06
- Re: [gforth] naive fibonacci, Elko Tchernev, 2010/03/06
- Re: [gforth] naive fibonacci,
Terrence Brannon <=
- Re: [gforth] naive fibonacci, Elko Tchernev, 2010/03/07
- RE: [gforth] naive fibonacci, Dennis Ruffer, 2010/03/07
- Re: [gforth] List strangeness, Elko Tchernev, 2010/03/07
- RE: [gforth] List strangeness, Dennis Ruffer, 2010/03/07
- Re: [gforth] List strangeness, Anton Ertl, 2010/03/08
- Re: [gforth] List strangeness, Elko Tchernev, 2010/03/08