[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
RE: [gforth] naive fibonacci
From: |
Dennis Ruffer |
Subject: |
RE: [gforth] naive fibonacci |
Date: |
Sat, 6 Mar 2010 18:36:37 -0800 |
> -----Original Message-----
> From: address@hidden [mailto:gforth-
> address@hidden 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
- [gforth] naive fibonacci, Terrence Brannon, 2010/03/06
- RE: [gforth] naive fibonacci,
Dennis Ruffer <=
- Re: [gforth] naive fibonacci, Elko Tchernev, 2010/03/06
- Re: [gforth] naive fibonacci, Terrence Brannon, 2010/03/07
- 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