Hi,

I am trying to make a little example with a while loop. I plan to use  
it in another context so I'd like to avoid using ranges (unless you  
show me how to represent infinite sequences like all integers). The  
code doesn't work because the n in "n dec" is not a symbol ? Nor a  
variable ? I still don't understand how to use symbols because I  
thought that I could avoid using SYMBOL: and still get the benefit of  
variables.
I could do it with recursion (as with the test2 word) but instead I  
try to use the while word specifically.

Could you please show me how to rewrite my example ? Or maybe I cannot  
alter the value of n inside [let.

TIA

Ludovic Kuty

! INFINITE LOOP !!!!! BUG
: test ( -- )
   [let | n [ 10 ] | [ n zero? not ] [ n dec n "%d\n" printf ] while ]
;

! OK but I do not want this
:: test2 ( n -- )
   n zero? [ ] [ n "%d\n" printf n 1 - test2 ] if
;


------------------------------------------------------------------------------
This SF.net email is sponsored by:
High Quality Requirements in a Collaborative Environment.
Download a free trial of Rational Requirements Composer Now!
http://p.sf.net/sfu/www-ibm-com
_______________________________________________
Factor-talk mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/factor-talk

Reply via email to