On Tue, Aug 16, 2011 at 4:57 PM, Larry Coleman
<all.are.wond...@gmail.com> wrote:
> This works, but I'm pretty sure it's not idiomatic factor, and I'll
> need to do something similar at least twice more, so there must be a
> better way:
>
> TUPLE: item-info longitude latitude speed ;
>
> C: <item-info> item-info
>
> : stats>item-info ( stats -- item-info )
>    {
>        [ 0 swap nth ]
>        [ 1 swap nth ]
>        [ 3 swap nth ]
>    } cleave <item-info> ;
>
> So what is the idiomatic way to get a items out of an array based on a
> sequence of indexes?

In this specific case, you can do the following:

first3 <item-info>

However in the general case (selecting arbitrary indices) you can do
what Doug suggested.

Slava

------------------------------------------------------------------------------
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

Reply via email to