sequences: update each-index and map-index to not depend on integers-as-sequences
parent
a5cd2202ff
commit
dd61b59937
|
@ -358,8 +358,14 @@ PRIVATE>
|
||||||
|
|
||||||
<PRIVATE
|
<PRIVATE
|
||||||
|
|
||||||
|
: ((each)) ( seq -- n quot )
|
||||||
|
[ length ] keep [ nth-unsafe ] curry ; inline
|
||||||
|
|
||||||
: (each) ( seq quot -- n quot' )
|
: (each) ( seq quot -- n quot' )
|
||||||
[ [ length ] keep [ nth-unsafe ] curry ] dip compose ; inline
|
[ ((each)) ] dip compose ; inline
|
||||||
|
|
||||||
|
: (each-index) ( seq quot -- n quot' )
|
||||||
|
[ ((each)) [ keep ] curry ] dip compose ; inline
|
||||||
|
|
||||||
: (collect) ( quot into -- quot' )
|
: (collect) ( quot into -- quot' )
|
||||||
[ [ keep ] dip set-nth-unsafe ] 2curry ; inline
|
[ [ keep ] dip set-nth-unsafe ] 2curry ; inline
|
||||||
|
@ -498,11 +504,8 @@ PRIVATE>
|
||||||
: follow ( obj quot -- seq )
|
: follow ( obj quot -- seq )
|
||||||
[ dup ] swap [ keep ] curry produce nip ; inline
|
[ dup ] swap [ keep ] curry produce nip ; inline
|
||||||
|
|
||||||
: prepare-index ( seq quot -- seq n quot )
|
|
||||||
[ dup length ] dip ; inline
|
|
||||||
|
|
||||||
: each-index ( seq quot -- )
|
: each-index ( seq quot -- )
|
||||||
prepare-index 2each ; inline
|
(each-index) each-integer ; inline
|
||||||
|
|
||||||
: interleave ( seq between quot -- )
|
: interleave ( seq between quot -- )
|
||||||
swap [ drop ] [ [ 2dip call ] 2curry ] 2bi
|
swap [ drop ] [ [ 2dip call ] 2curry ] 2bi
|
||||||
|
@ -510,7 +513,7 @@ PRIVATE>
|
||||||
each-index ; inline
|
each-index ; inline
|
||||||
|
|
||||||
: map-index ( seq quot -- newseq )
|
: map-index ( seq quot -- newseq )
|
||||||
prepare-index 2map ; inline
|
[ dup length iota ] dip 2map ; inline
|
||||||
|
|
||||||
: reduce-index ( seq identity quot -- )
|
: reduce-index ( seq identity quot -- )
|
||||||
swapd each-index ; inline
|
swapd each-index ; inline
|
||||||
|
|
Loading…
Reference in New Issue