sequences.extras vocabulary
Factor handbook ยป Vocabulary index


Summary
Contains sequence operations that are not commonly needed. Most of these words are elaborations on functions already available in the main sequences vocabulary.

Metadata
Parents:sequences
Tags:sequences


Words

Tuple classes
ClassSuperclassSlots
evens sequence-view
odds sequence-view
slice-error-of tuplefrom to seq
slices-don't-touch tupleslice1 slice2
step-slice tuplefrom to seq step
underlying-mismatch tupleslice1 slice2
virtual-zip-index tupleseq


Ordinary words
WordStack effect
(2selector-as)( quot length exemplar -- selector accum )
(collect-with-previous)( quot into -- quot' )
(each-integer-with-previous)( ... prev i n quot: ( ... i -- ... ) -- ... )
(start-all)( seq subseq increment -- indices )
0accumulate( ... seq quot: ( ... prev elt -- ... next ) -- ... final newseq )
0accumulate-as( ... seq quot: ( ... prev elt -- ... next ) exemplar -- ... newseq )
0reduce( seq quot: ( ..a prev elt -- ..a next ) -- result )
1reduce( seq quot: ( ..a prev elt -- ..a next ) -- result )
2count( ... seq1 seq2 quot: ( ... elt1 elt2 -- ... ? ) -- ... n )
2each-index( ... seq1 seq2 quot: ( ... elt1 elt2 index -- ... ) -- ... )
2filter( ... seq1 seq2 quot: ( ... elt1 elt2 -- ... newelt ) -- ... newseq )
2filter-as( ... seq1 seq2 quot: ( ... elt1 elt2 -- ... newelt ) exemplar -- ... newseq )
2filter-map( ... seq1 seq2 filter-quot: ( ... elt1 elt2 -- ... ? ) map-quot: ( elt1 elt2 -- obj ) -- ... newseq )
2filter-map*( ... seq1 seq2 quot: ( ... elt1 elt2 -- ... ? ) -- ... newseq )
2filter-map-as( ... seq1 seq2 filter-quot: ( ... elt1 elt2 -- ... ? ) map-quot: ( elt1 elt2 -- obj ) exemplar -- ... newseq )
2filter-map-as*( ... seq1 seq2 quot: ( ... elt1 elt2 -- ... obj ? ) exemplar -- ... newseq )
2map!( ... seq1 seq2 quot: ( ... elt1 elt2 -- ... newelt ) -- ... seq1 )
2map-index( ... seq1 seq2 quot: ( ... elt1 elt2 index -- ... newelt ) -- ... newseq )
2map-into( seq1 seq2 quot into -- )
2map-sum( ... seq1 seq2 quot: ( ... elt1 elt2 -- ... n ) -- ... n )
2nested-each( seq1 seq2 quot -- )
2nested-each*( seq1 seq-quot: ( n -- seq ) quot: ( a b -- ) -- )
2nested-filter( seq1 seq2 quot -- seq )
2nested-filter*( seq1 seq-quot quot -- seq )
2nested-filter-as( seq1 seq2 quot exemplar -- seq )
2nested-filter-as*( seq1 seq-quot quot exemplar -- seq )
2nested-map( seq1 seq2 quot -- seq )
2nested-map*( seq1 seq-quot quot -- seq )
2nested-map-as( seq1 seq2 quot exemplar -- seq )
2nested-map-as*( seq1 seq-quot quot exemplar -- seq )
2push-when( ..a elt1 elt2 quot: ( ..a elt1 elt2 -- ..b ? ) accum -- ..b )
2reduce-from( ... seq1 seq2 identity quot: ( ... prev elt1 elt2 -- ... next ) i -- ... result )
2reject( ... seq1 seq2 quot: ( ... elt1 elt2 -- ... newelt ) -- ... newseq )
2reject-as( ... seq1 seq2 quot: ( ... elt1 elt2 -- ... newelt ) exemplar -- ... newseq )
2reject-map( ... seq1 seq2 quot: ( ... elt1 elt2 -- ... ? ) map-quot: ( elt1 elt2 -- obj ) -- ... newseq )
2reject-map*( ... seq1 seq2 quot: ( ... elt1 elt2 -- ... obj ? ) -- ... newseq )
2reject-map-as( ... seq1 seq2 quot: ( ... elt1 elt2 -- ... ? ) map-quot: ( elt1 elt2 -- obj ) exemplar -- ... newseq )
2reject-map-as*( ... seq1 seq2 quot: ( ... elt1 elt2 -- ... obj ? ) exemplar -- ... newseq )
3each-from( ... seq1 seq2 seq3 quot: ( ... elt1 elt2 elt3 -- ... ) i -- ... )
3map-reduce( ..a seq1 seq2 seq3 map-quot: ( ..a elt1 elt2 elt3 -- ..b intermediate ) reduce-quot: ( ..b prev intermediate -- ..a next ) -- ..a result )
3nested-each( seq1 seq2 seq3 quot -- )
3nested-filter( seq1 seq2 seq3 quot -- seq )
3nested-filter-as( seq1 seq2 seq3 quot exemplar -- seq )
3nested-map( seq1 seq2 seq3 quot -- seq )
3nested-map-as( seq1 seq2 seq3 quot exemplar -- seq )
<evens>( seq -- evens )
<odds>( seq -- odds )
<step-slice>( from/f to/f step seq -- step-slice )
<zip-index>( seq -- virtual-zip-index )
>resizable( seq -- accum )
>string-list( seq -- seq' )
?<slice>( from/f to/f sequence -- slice )
??nth( n seq -- elt/f ? )
??nth-of( seq n -- elt/f ? )
??prev( n seq -- obj/f ? )
??prev-of( seq n -- obj/f ? )
?cut( seq n -- before after )
?first2( seq -- first/f second/f )
?first3( seq -- first/f second/f third/f )
?first4( seq -- first/f second/f third/f fourth/f )
?heap-pop-value>array( heap -- array )
?infimum( seq/f -- elt/f )
?maximum( seq/f -- elt/f )
?minimum( seq/f -- elt/f )
?nth-of( seq n -- elt/f )
?prev( n seq -- obj/f )
?prev-of( seq n -- obj/f )
?span-slices( slice1/f slice2/f -- slice )
?supremum( seq/f -- elt/f )
?trim( seq quot: ( elt -- ? ) -- seq/newseq )
?trim-head( seq quot: ( elt -- ? ) -- seq/newseq )
?trim-tail( seq quot: ( elt -- ? ) -- seq/newseq )
?unclip( seq -- rest/f first/f )
accumulate-of( seq quot: ( prev elt -- next ) identity -- result )
all-longest( seqs -- seqs' )
all-rotations( seq -- seq' )
all-shortest( seqs -- seqs' )
all-subseqs( seq -- seqs )
appender( quot -- appender accum )
appender-for( quot exemplar -- appender accum )
arg-max( seq -- n )
arg-min( seq -- n )
arg-sort( seq -- indices )
arg-where( ... seq quot: ( ... elt -- ... ? ) -- ... indices )
assoc-zip-with( quot: ( key value -- calc ) -- alist )
at+*( n key assoc -- old new )
bqn-index( seq1 seq2 -- seq )
bqn-index-as( seq1 seq2 exemplar -- seq )
bqn-index-by( seq1 seq2 quot -- seq )
bqn-index-by-as( seq1 seq2 quot exemplar -- seq )
call-push-when( ..a elt quot: ( ..a elt -- ..b elt' ? ) accum -- ..b )
change-last( seq quot -- )
change-last-unsafe( seq quot -- )
change-nths( ... indices seq quot: ( ... elt -- ... elt' ) -- ... )
check-slice-of( seq from to -- seq from to )
classify( seq -- seq' )
classify*( seq -- next hash seq' )
classify-from( next hash seq -- next' hash seq' )
collapse( ... seq quot: ( ... elt -- ... ? ) elt -- ... seq' )
collect-with-previous( n quot into -- )
compact( ... seq quot: ( ... elt -- ... ? ) elt -- ... seq' )
count-head( seq quot -- n )
count-subseq( seq subseq -- n )
count-subseq*( seq subseq -- n )
count-tail( seq quot -- n )
count=( ... seq quot: ( ... elt -- ... ? ) n -- ... ? )
cut-when( ... seq quot: ( ... elt -- ... ? ) -- ... before after )
deduplicate( seq -- seq' )
deduplicate-last( seq -- seq' )
delete-slice-of( seq from to -- seq )
drop-while( ... seq quot: ( ... elt -- ... ? ) -- tail-slice )
each-index-from( ... seq quot: ( ... elt index -- ... ) i -- ... )
each-integer-with-previous( ... n quot: ( ... i -- ... ) -- ... )
each-prior( ... seq quot: ( ... prior elt -- ... ) -- ... )
each-prior-from( ... i seq quot: ( ... prior elt -- ... ) -- ... )
each-prior-identity-from( ... identity i seq quot: ( ... prior elt -- ... ) -- ... )
each-subseq( ... seq quot: ( ... subseq -- ... ) -- ... )
ensure-same-underlying( slice1 slice2 -- slice1 slice2 )
even-indices( seq -- seq' )
exchange-subseq( len pos1 pos2 seq -- )
extract!( ... seq quot: ( ... elt -- ... ? ) -- ... seq )
filter-all-subseqs( ... seq quot: ( ... subseq -- ... ? ) -- seq )
filter-all-subseqs-range( ... seq range quot: ( ... subseq -- ... ? ) -- seq )
filter-index( ... seq quot: ( ... elt i -- ... ? ) -- ... seq' )
filter-index-as( ... seq quot: ( ... elt i -- ... ? ) exemplar -- ... seq' )
filter-length( seq n -- seq' )
filter-map( ... seq filter-quot: ( ... elt -- ... ? ) map-quot: ( obj -- obj' ) -- ... newseq )
filter-map*( ... seq quot: ( ... elt -- ... newelt ? ) -- ... newseq )
filter-map-as( ... seq filter-quot: ( ..a elt -- ..b ? ) map-quot: ( obj -- obj' ) exemplar -- ... newseq )
filter-map-as*( ... seq quot: ( ..a elt -- ..b obj ? ) exemplar -- ... newseq )
find*( ... seq quot: ( ... elt -- ... ? ) -- ... elt i/f )
find-all( ... seq quot: ( ... elt -- ... ? ) -- ... elts )
find-deep( ... seq quot: ( ... elt -- ... calc ) -- ... calc/f )
find-from*( ... n seq quot: ( ... elt -- ... ? ) -- ... elt i/f )
find-index*( ... seq quot: ( ... elt i -- ... ? ) -- ... elt i/f )
find-index-from*( ... n seq quot: ( ... elt i -- ... ? ) -- ... elt i/f )
find-last*( ... seq quot: ( ... elt -- ... ? ) -- ... elt i/f )
find-last-from*( ... n seq quot: ( ... elt -- ... ? ) -- ... elt i/f )
find-last-index( ... seq quot: ( ... elt i -- ... ? ) -- ... i elt )
find-last-index-from( ... n seq quot: ( ... elt i -- ... ? ) -- ... i elt )
find-nth( nth seq quot: ( obj -- ? ) -- i/f obj/f )
find-nth-from( nth from seq quot: ( obj -- ? ) -- i/f obj/f )
find-nth-last( nth seq quot: ( obj -- ? ) -- i/f obj/f )
find-nth-last-from( nth from seq quot: ( obj -- ? ) -- i/f obj/f )
find-pred( ... seq quot: ( ... elt -- ... calc ) pred: ( ... calc -- ... ? ) -- ... calc/f i/f elt/f )
find-pred-loop( ... i n seq quot: ( ... elt -- ... calc ? ) -- ... calc/f i/f elt/f )
first=( seq elt -- ? )
first?( ... seq quot: ( ... elt -- ... ? ) -- ... ? )
fourth=( seq elt -- ? )
fourth?( ... seq quot: ( ... elt -- ... ? ) -- ... ? )
fry-map-as( seq quot exemplar -- newseq )
harvest!( seq -- newseq )
harvest-as( seq exemplar -- newseq )
head*-as( seq n exemplar -- seq' )
head-as( seq n exemplar -- seq' )
heap>pairs( heap -- pairs )
inc-at*( key assoc -- old new )
index*( seq obj -- n )
index-from*( i seq obj -- n )
index-selector( quot -- selector accum )
index-selector-as( quot exemplar -- selector accum )
indices*( seq obj -- indices )
infimum-by*( ... seq quot: ( ... elt -- ... x ) -- ... i elt )
insert-nth!( elt n seq -- )
interleaved( seq glue -- newseq )
interleaved-as( seq glue exemplar -- newseq )
iterate-heap-while( heap quot1: ( value key -- slurp? ) quot2: ( value key -- obj/f ) -- obj/f loop? )
last-index*( seq obj -- n )
last-index-from*( i seq obj -- n )
last=( seq elt -- ? )
last?( ... seq quot: ( ... elt -- ... ? ) -- ... ? )
longest-subseq( seq1 seq2 -- subseq )
loop>array( ... quot: ( ... -- ... obj/f ) -- ... array )
loop>array*( ... quot: ( ... -- ... obj ? ) -- ... array )
loop>array**( ... quot: ( ... -- ... obj ? ) -- ... array )
loop>sequence( ... quot: ( ... -- ... obj/f ) exemplar -- ... seq )
loop>sequence*( ... quot: ( ... -- ... obj ? ) exemplar -- ... seq )
loop>sequence**( ... quot: ( ... -- ... obj ? ) exemplar -- ... seq )
map-concat( ... seq quot: ( ... elt -- ... newelt ) -- ... newseq )
map-concat-as( ... seq quot: ( ... elt -- ... newelt ) exemplar -- ... newseq )
map-filter( ... seq map-quot: ( ... elt -- ... newelt ) filter-quot: ( ... newelt -- ... ? ) -- ... subseq )
map-filter-as( ... seq map-quot: ( ... elt -- ... newelt ) filter-quot: ( ... newelt -- ... ? ) exemplar -- ... subseq )
map-find-index( ... seq quot: ( ... elt index -- ... result/f ) -- ... result i elt )
map-find-last-index( ... seq quot: ( ... elt index -- ... result/f ) -- ... result i elt )
map-from( ... seq quot: ( ... elt -- ... newelt ) from -- ... newseq )
map-from-as( ... seq quot: ( ... elt -- ... newelt ) from exemplar -- ... newseq )
map-harvest( ... seq quot: ( ... elt -- ... newelt ) -- ... newseq )
map-if( ... seq if-quot: ( ... elt -- ... ? ) map-quot: ( ... elt -- ... newelt ) -- ... newseq )
map-index!( ... seq quot: ( ... elt index -- ... newelt ) -- ... seq )
map-infimum( seq quot: ( ... elt -- ... elt' ) -- elt' )
map-integers-with( ... len quot: ( ... prev i -- ... elt ) exemplar -- ... newseq )
map-like( seq exemplar -- seq' )
map-maximum( seq quot: ( ... elt -- ... elt' ) -- elt' )
map-minimum( seq quot: ( ... elt -- ... elt' ) -- elt' )
map-prior( ... seq quot: ( ... prior elt -- elt' ) -- seq' )
map-prior-as( ... seq quot: ( ... prior elt -- elt' ) exemplar -- seq' )
map-prior-from( ... i seq quot: ( ... prior elt -- elt' ) -- seq' )
map-prior-from-as( ... i seq quot: ( ... prior elt -- elt' ) exemplar -- seq' )
map-prior-identity-as( ... identity seq quot: ( ... prior elt -- elt' ) exemplar -- seq' )
map-prior-identity-from-as( ... identity i seq quot: ( ... prior elt -- elt' ) exemplar -- seq' )
map-product( ... seq quot: ( ... elt -- ... n ) -- ... n )
map-sift( ... seq quot: ( ... elt -- ... newelt ) -- ... newseq )
map-supremum( seq quot: ( ... elt -- ... elt' ) -- elt' )
map-with-previous( ... seq quot: ( ... elt prev/f -- ... newelt ) -- ... newseq )
map-with-previous-as( ... seq quot: ( ... elt prev/f -- ... newelt ) exemplar -- ... newseq )
map-zip-swap( quot: ( x -- y ) -- alist )
mark-firsts( seq -- seq' )
max-subarray-sum( seq -- sum )
maximum-by*( ... seq quot: ( ... elt -- ... x ) -- ... i elt )
maybe-push( elt/f accum -- )
member-eq-of?( seq elt -- ? )
member-of?( seq elt -- ? )
merge-slices( slice1 slice2 -- slice/* )
minimum-by*( ... seq quot: ( ... elt -- ... x ) -- ... i elt )
mismatch-last( seq1 seq2 -- i-back )
nth*( n seq -- elt )
nth-index( n obj seq -- i )
nth-of( seq n -- elt )
nth=( n seq elt -- ? )
nth?( ... n seq quot: ( ... elt -- ... ? ) -- ... ? )
occurrence-count-by( seq quot: ( elt -- elt' ) -- hash seq' )
odd-indices( seq -- seq' )
one?( ... seq quot: ( ... elt -- ... ? ) -- ... ? )
ordered-slices-overlap?( slice-lt slice-gt -- ? )
ordered-slices-range( slice-lt slice-gt -- to from )
ordered-slices-touch?( slice-lt slice-gt -- ? )
pad-center( seq n elt -- padded )
pad-longest( seq1 seq2 elt -- seq1 seq2 )
percent-of( ... seq quot: ( ... elt -- ... ? ) -- ... % )
prepend-lines-with-spaces( str -- str' )
prev( n seq -- obj )
prev-identity( i seq -- identity i seq )
prev-of( seq n -- obj )
progressive-index( seq1 seq2 -- hash seq )
progressive-index-as( seq1 seq2 exemplar -- hash seq )
progressive-index-by( seq1 seq2 quot -- hash seq )
progressive-index-by-as( seq1 seq2 quot exemplar -- hash seq )
push-if*( ..a elt quot: ( ..a elt -- ..b obj/f ) accum -- ..b )
push-if-index( ..a elt i quot: ( ..a elt i -- ..b ? ) accum -- ..b )
reduce-from( ... seq identity quot: ( ... prev elt -- ... next ) from -- ... result )
reduce-of( seq quot: ( prev elt -- next ) identity -- result )
reject-map( ... seq filter-quot: ( ... elt -- ... ? ) map-quot: ( obj -- obj' ) -- ... newseq )
reject-map*( ... seq quot: ( ... elt -- ... newelt ? ) -- ... newseq )
reject-map-as( ... seq filter-quot: ( ... elt -- ... ? ) map-quot: ( obj -- obj' ) exemplar -- ... newseq )
reject-map-as*( ... seq quot: ( ... elt -- ... newelt ? ) exemplar -- ... newseq )
remove-eq-of( seq elt -- newseq )
remove-first( obj seq -- seq' )
remove-first!( obj seq -- seq )
remove-first-of( seq obj -- seq' )
remove-last( obj seq -- seq' )
remove-last!( obj seq -- seq )
remove-nth-of( seq n -- seq' )
remove-nth-of!( seq n -- seq )
remove-nth-of*( seq n -- nth seq' )
remove-nth-of*!( seq n -- nth seq )
remove-of( seq elt -- newseq )
replicate-into( ... seq quot: ( ... -- ... newelt ) -- ... )
reverse-as( seq exemplar -- newseq )
rotate( seq n -- seq' )
rotate!( seq n -- )
round-robin( seq -- newseq )
safe-subseq( from to seq -- subseq )
second=( seq elt -- ? )
second?( ... seq quot: ( ... elt -- ... ? ) -- ... ? )
selector*( quot -- selector accum )
selector-as*( quot exemplar -- selector accum )
sequence-cartesian-product( seqs -- seqs' )
sequence-index-operator-last( n seq quot -- n quot' )
sequence>slice( sequence -- slice )
set-nth-of( seq n elt -- seq )
set-nths( value indices seq -- )
set-nths-unsafe( value indices seq -- )
setup-each-from( seq quot -- n quot )
shorten*( vector n -- seq )
sift!( seq -- seq' )
sift-as( seq exemplar -- newseq )
slice-error-of( from to seq -- * )
slice-order-by-from( slice1 slice2 -- slice-lt slice-gt )
slice-when( seq quot: ( elt -- ? ) -- seq' )
slices-don't-touch( slice1 slice2 -- * )
slices-overlap?( slice1 slice2 -- ? )
slices-touch?( slice1 slice2 -- ? )
slurp-heap-while-map( heap quot1: ( value key -- slurp? ) quot2: ( value key -- obj/f ) -- seq )
snip-of( seq from to -- head tail )
snip-slice-of( seq from to -- head tail )
span-slices( slice1 slice2 -- slice )
start-all( seq subseq -- indices )
start-all*( seq subseq -- indices )
subseq*( from to seq -- subseq )
subseq-indices( seq subseq -- indices )
supremum-by*( ... seq quot: ( ... elt -- ... x ) -- ... i elt )
tail*-as( seq n exemplar -- seq' )
tail-as( seq n exemplar -- seq' )
take-while( ... seq quot: ( ... elt -- ... ? ) -- head-slice )
third=( seq elt -- ? )
third?( ... seq quot: ( ... elt -- ... ? ) -- ... ? )
trim-as( ... seq quot: ( ... elt -- ... ? ) exemplar -- ... newseq )
underlying-mismatch( slice1 slice2 -- * )
unordered-slices-overlap?( slice1 slice2 -- ? )
unordered-slices-range( slice1 slice2 -- to from )
unordered-slices-touch?( slice1 slice2 -- ? )
unsurround( newseq seq2 seq3 -- seq1 )
until-empty( seq quot -- )
with-string-lines( str quot -- str' )
zero-loop>array( quot: ( ..a n -- ..a obj ) -- seq )
zero-loop>sequence( ... quot: ( ... n -- ... obj/f ) exemplar -- ... seq )
zip-longest( seq1 seq2 -- assoc )
zip-longest-with( seq1 seq2 fill -- assoc )


Class predicate words
WordStack effect
evens?( object -- ? )
odds?( object -- ? )
slice-error-of?( object -- ? )
slices-don't-touch?( object -- ? )
step-slice?( object -- ? )
underlying-mismatch?( object -- ? )
virtual-zip-index?( object -- ? )


Files


Metadata files