sequences.lib: indices
parent
7a5d48cadb
commit
8cfc644893
|
@ -140,3 +140,13 @@ PRIVATE>
|
||||||
: ?second ( seq -- second/f ) 1 swap ?nth ; inline
|
: ?second ( seq -- second/f ) 1 swap ?nth ; inline
|
||||||
: ?third ( seq -- third/f ) 2 swap ?nth ; inline
|
: ?third ( seq -- third/f ) 2 swap ?nth ; inline
|
||||||
: ?fourth ( seq -- fourth/f ) 3 swap ?nth ; inline
|
: ?fourth ( seq -- fourth/f ) 3 swap ?nth ; inline
|
||||||
|
|
||||||
|
! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
|
||||||
|
|
||||||
|
! List the positions of obj in seq
|
||||||
|
|
||||||
|
: indices ( seq obj -- seq )
|
||||||
|
>r dup length swap r>
|
||||||
|
[ = [ ] [ drop f ] if ] curry
|
||||||
|
2map
|
||||||
|
[ ] subset ;
|
||||||
|
|
Loading…
Reference in New Issue