The example for the produce word is basically your solution already. \ produce help
click the example It should look like this: USING: kernel math prettyprint sequences ; 1337 [ dup 0 > ] [ 2/ dup ] produce nip . { 668 334 167 83 41 20 10 5 2 1 0 } This is basically John's solution, too. Cheers, Doug On Tue, Jun 19, 2012 at 8:09 PM, Marshall Lochbaum <mwlochb...@gmail.com> wrote: > I figured there would be a word designed for that already... Here's my take > on this anyway. > > I would append the items to a sequence as the algorithm goes along: > > { } swap [ dup 1 > ] [ dup 2 /i [ suffix ] dip ] while suffix > > accomplishes the task. > > Marshall > > On Tue, Jun 19, 2012 at 10:50 PM, Graham Telfer <gakouse...@hotmail.com> > wrote: >> >> Doug Coleman <doug.coleman@...> writes: >> >> > >> > In general, you shouldn't want to do this, as all Factor words >> > (besides the one I'm about to show you) need a fixed number of >> > parameters at compile-time. Macros expand at compile-time, so that's >> > one way to get around the restriction. >> > >> > The other way it to use a slow word called with-datastack: >> > >> > { 1 2 } [ + ] with-datastack >> > >> > You can also use smart combinators: >> > >> > [ 2 1 - 3 ] sum-outputs >> > >> > This works because the quotation infers at compile-time, and >> > sum-outputs is a "smart" combinator that expands based on the number >> > of outputs inferred. >> > >> > You are trying to do a C varargs function, basically, and just as in >> > C, most Factor words are not varags. >> > >> > If you have more details about what you want to program, we could help >> > you! >> > >> > Doug >> >> Hi Doug, >> >> 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. >> >> >> >> ------------------------------------------------------------------------------ >> 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 > > > > ------------------------------------------------------------------------------ > 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 > ------------------------------------------------------------------------------ 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