>
> I want to divide an integer by 2 until it gets to 1.
>
> I have this snippet of code that goes into a loop.
>
> dup 1 > [ dup 2 /i ] [  ] if
>
> When it gets to 1 I want to push the elements into a sequence.
>

Take a look at the "produce" word:

: divide-until-2 ( n -- seq )
    [ dup 1 > ] [ 2 /i dup ] produce nip ;
------------------------------------------------------------------------------
Live Security Virtual Conference
Exclusive live event will cover all the ways today's security and 
threat landscape has changed and how IT managers can respond. Discussions 
will include endpoint security, mobile security and the latest in malware 
threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/
_______________________________________________
Factor-talk mailing list
Factor-talk@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/factor-talk

Reply via email to