On Thu, Jan 10, 2013 at 11:44 AM, Alex Vondrak <[email protected]> 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 > If the iteration variable is just indexing into a sequence, you can use > http://docs.factorcode.org/content/word-each-index%2Csequences.html > "while" loops: http://docs.factorcode.org/content/word-while,kernel.htmland > the variant > http://docs.factorcode.org/content/word-until%2Ckernel.html > > There are other variants; take a look through the words defined in vocabs > like `sequences`. All else fails, there's good ol' fashioned tail > recursion: http://docs.factorcode.org/content/article-tail-call-opt.html > > Hope these help, > --Alex Vondrak > Was wondering if there could be a variation of "for i = 0 up to n", when n is unknown. Named it "index-pump". Instead of "looping over a body of code", we are "index-pumping a function". : index-pump ( quot -- m ) 1 swap [ dup ] prepose [ 1 + ] while ; inline
fibonacci.factor
Description: Binary data
------------------------------------------------------------------------------ Master Java SE, Java EE, Eclipse, Spring, Hibernate, JavaScript, jQuery and much more. Keep your Java skills current with LearnJavaNow - 200+ hours of step-by-step video tutorials by Java experts. SALE $49.99 this month only -- learn more at: http://p.sf.net/sfu/learnmore_122612
_______________________________________________ Factor-talk mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/factor-talk
