This should be a direct translation of that method, I think

:: fibonacci? ( n )
    1 [ dup fibonacci n < ] [ 1 + ] while fibonacci n = ;


On Thu, Jan 10, 2013 at 10:03 PM, Leonard P <leonard14...@gmail.com> wrote:

> On Thu, Jan 10, 2013 at 11:44 AM, Alex Vondrak <ajvond...@gmail.com>wrote:
>
>> Haven't looked at the code, but to answer your question about
>> `for`-loops...
>>
>> "for each" loops:
>> http://docs.factorcode.org/content/word-each,sequences.html
>> "for i = 0 up to n" loops: use `each` with
>> http://docs.factorcode.org/content/word-iota,sequences.html
>>
>
> It seems that Factor has a rich facility for dealing with sequences.
>
> What I'm looking for, though, is something that could do this ...
>
> boolean fibonacci?( int n ) {
>    int i = 1;
>    while( fibonacci( i ) < n ) {
>        i++;
>    }
>     return fibonacci( i ) == n;
> }
>
> Basically wondering how to maintain a counter in a while loop.
>
>
>
>
> ------------------------------------------------------------------------------
> Master HTML5, CSS3, ASP.NET, MVC, AJAX, Knockout.js, Web API and
> much more. Get web development skills now with LearnDevNow -
> 350+ hours of step-by-step video tutorials by Microsoft MVPs and experts.
> SALE $99.99 this month only -- learn more at:
> http://p.sf.net/sfu/learnmore_122812
> _______________________________________________
> Factor-talk mailing list
> Factor-talk@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/factor-talk
>
>
------------------------------------------------------------------------------
Master HTML5, CSS3, ASP.NET, MVC, AJAX, Knockout.js, Web API and
much more. Get web development skills now with LearnDevNow -
350+ hours of step-by-step video tutorials by Microsoft MVPs and experts.
SALE $99.99 this month only -- learn more at:
http://p.sf.net/sfu/learnmore_122812
_______________________________________________
Factor-talk mailing list
Factor-talk@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/factor-talk

Reply via email to