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

Reply via email to