Eduardo Cavazos wrote:

> > There's an 'indices' in 'sequences.lib':
> > : indices ( seq obj -- seq )
> > :
> >   >r dup length swap r>
> >
> >   [ = [ ] [ drop f ] if ] curry
> >   2map
> >   sift ;

On Saturday 26 July 2008 05:53:35 Phil Dawes wrote:

> Do you mind if I substitute my (now renamed!) implementation into
> sequences.lib? - it's coming in at ~ twice as fast for large arrays in
>
> my timings.:
> : (indices) ( seq obj n -- )
>
>     [ 2dup ] dip rot index-from [ dup , 1+ (indices) ] [ 2drop ] if* ;
>
> : indices ( seq obj -- idxseq )
>
>     [ 0 (indices) ] { } make ;

Phil,

Looks good.

How does this implementation fare in your tests?

: indices ( seq obj -- indices )
  over length <vector> -rot
  [ rot = [ over push ] [ drop ] if ]
  curry
  each-index
  >array ;

Whatever you find, feel free to check in the best performing one.

Ed

-------------------------------------------------------------------------
This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
Build the coolest Linux based applications with Moblin SDK & win great prizes
Grand prize is a trip for two to an Open Source event anywhere in the world
http://moblin-contest.org/redirect.php?banner_id=100&url=/
_______________________________________________
Factor-talk mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/factor-talk

Reply via email to