Typically there are better ways to operate on sequences than to put all the
elements on the stack, but you could:

    ( scratchpad ) { 0 1 2 3 } dup length firstn

Better might be to use some combinators to act on the sequence each grabbing
the element that they need (bi, tri, or the more general cleave):

    ( scratchpad ) { 0 1 2 3 } {
                      [ first ]
                      [ second ]
                      [ third ]
                   } cleave




On Wed, Aug 24, 2011 at 6:50 PM, Andrew Pennebaker <
andrew.penneba...@gmail.com> wrote:

> Is there a word more general than firstn? I'd like to push all the elements
> of a sequence onto the stack.
>
>
> Cheers,
>
> Andrew Pennebaker
> www.yellosoft.us
>
> On Sun, Aug 21, 2011 at 2:26 PM, Alexander J. Vondrak <
> ajvond...@csupomona.edu> wrote:
>
>> first2: http://docs.factorcode.org/content/word-first2,sequences.html
>>
>> In general, firstn:
>> http://docs.factorcode.org/content/word-firstn,sequences.generalizations.html
>>
>> Regards,
>> --Alex Vondrak
>> ________________________________________
>> From: Andrew Pennebaker [andrew.penneba...@gmail.com]
>> Sent: Sunday, August 21, 2011 11:20 AM
>> To: Factor
>> Subject: [Factor-talk] sequences and the stack
>>
>> The stack contains a sequence of number pairs:
>>
>> { { x1 y1 } { x2 y2 } { x3 y3 } ... }
>>
>> I want to map over the pairs, accessing xi and yi.
>>
>> [
>>   ! stack = { xi yi }
>>
>>   ! ...
>>
>>   ! stack = xi yi
>> ] map
>>
>> What's the code that goes in !... ?
>>
>> Other than using nth, how can I do this? Is there a word that pops the
>> elements of a sequence onto the stack?
>>
>> Cheers,
>>
>> Andrew Pennebaker
>> www.yellosoft.us<http://www.yellosoft.us>
>>
>>
>> ------------------------------------------------------------------------------
>> Get a FREE DOWNLOAD! and learn more about uberSVN rich system,
>> user administration capabilities and model configuration. Take
>> the hassle out of deploying and managing Subversion and the
>> tools developers use with it. http://p.sf.net/sfu/wandisco-d2d-2
>> _______________________________________________
>> Factor-talk mailing list
>> Factor-talk@lists.sourceforge.net
>> https://lists.sourceforge.net/lists/listinfo/factor-talk
>>
>
>
>
> ------------------------------------------------------------------------------
> EMC VNX: the world's simplest storage, starting under $10K
> The only unified storage solution that offers unified management
> Up to 160% more powerful than alternatives and 25% more efficient.
> Guaranteed. http://p.sf.net/sfu/emc-vnx-dev2dev
> _______________________________________________
> Factor-talk mailing list
> Factor-talk@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/factor-talk
>
>
------------------------------------------------------------------------------
EMC VNX: the world's simplest storage, starting under $10K
The only unified storage solution that offers unified management 
Up to 160% more powerful than alternatives and 25% more efficient. 
Guaranteed. http://p.sf.net/sfu/emc-vnx-dev2dev
_______________________________________________
Factor-talk mailing list
Factor-talk@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/factor-talk

Reply via email to