sequences vocabulary
Factor handbook ยป Vocabulary index


Documentation
Sequence operations

Metadata
Tags:collections, sequences
Authors:Slava Pestov


Words

Tuple classes
ClassSuperclassSlots
assert-sequence tuplegot expected
bounds-error tupleindex seq
immutable tupleelement index sequence
iota tuplen
repetition tuplelength elt
reversed sequence-view
sequence-view tupleseq
slice tuplefrom to seq
slice-error tuplefrom to seq


Mixin classes
immutable-sequence
sequence
virtual-sequence
wrapped-sequence


Generic words
WordStack effect
bounds-check?( n seq -- ? )
clone-like( seq exemplar -- newseq )
length( seq -- n )
lengthen( n seq -- )
like( seq exemplar -- newseq )
maximum( seq -- elt )
minimum( seq -- elt )
new-resizable( len seq -- newseq )
new-sequence( len seq -- newseq )
nth( n seq -- elt )
set-length( n seq -- )
set-nth( elt n seq -- )
shorten( n seq -- )
sum( seq -- n )
sum-lengths( seq -- n )
virtual-exemplar( seq -- seq' )
virtual@( n seq -- n' seq' )


Ordinary words
WordStack effect
1sequence( obj exemplar -- seq )
1surround( seq1 seq2 -- newseq )
1surround-as( seq1 seq2 exemplar -- newseq )
2all?( ... seq1 seq2 quot: ( ... elt1 elt2 -- ... ? ) -- ... ? )
2any?( ... seq1 seq2 quot: ( ... elt1 elt2 -- ... ? ) -- ... ? )
2each( ... seq1 seq2 quot: ( ... elt1 elt2 -- ... ) -- ... )
2each-from( ... seq1 seq2 quot: ( ... elt1 elt2 -- ... ) from -- ... )
2length( seq1 seq2 -- n1 n2 )
2map( ... seq1 seq2 quot: ( ... elt1 elt2 -- ... newelt ) -- ... newseq )
2map-as( ... seq1 seq2 quot: ( ... elt1 elt2 -- ... newelt ) exemplar -- ... newseq )
2map-reduce( ..a seq1 seq2 map-quot: ( ..a elt1 elt2 -- ..a intermediate ) reduce-quot: ( ..a prev intermediate -- ..a next ) -- ..a result )
2reduce( ... seq1 seq2 identity quot: ( ... prev elt1 elt2 -- ... next ) -- ... result )
2selector( quot -- selector accum1 accum2 )
2sequence( obj1 obj2 exemplar -- seq )
3append( seq1 seq2 seq3 -- newseq )
3append-as( seq1 seq2 seq3 exemplar -- newseq )
3each( ... seq1 seq2 seq3 quot: ( ... elt1 elt2 elt3 -- ... ) -- ... )
3length( seq1 seq2 seq3 -- n1 n2 n3 )
3map( ... seq1 seq2 seq3 quot: ( ... elt1 elt2 elt3 -- ... newelt ) -- ... newseq )
3map-as( ... seq1 seq2 seq3 quot: ( ... elt1 elt2 elt3 -- ... newelt ) exemplar -- ... newseq )
3sequence( obj1 obj2 obj3 exemplar -- seq )
4sequence( obj1 obj2 obj3 obj4 exemplar -- seq )
<iota>( n -- iota )
<repetition>( len elt -- repetition )
<reversed>( seq -- reversed )
<slice>( from to seq -- slice )
>slice<( slice -- from to seq )
?first( seq -- elt/f )
?last( seq -- elt/f )
?nth( n seq -- elt/f )
?second( seq -- elt/f )
?set-nth( elt n seq -- )
accumulate( ... seq identity quot: ( ... prev elt -- ... next ) -- ... final newseq )
accumulate!( ... seq identity quot: ( ... prev elt -- ... next ) -- ... final seq )
accumulate*( ... seq identity quot: ( ... prev elt -- ... next ) -- ... newseq )
accumulate*!( ... seq identity quot: ( ... prev elt -- ... next ) -- ... seq )
accumulate*-as( ... seq identity quot: ( ... prev elt -- ... next ) exemplar -- ... newseq )
accumulate-as( ... seq identity quot: ( ... prev elt -- ... next ) exemplar -- ... final newseq )
all?( ... seq quot: ( ... elt -- ... ? ) -- ... ? )
any?( ... seq quot: ( ... elt -- ... ? ) -- ... ? )
append( seq1 seq2 -- newseq )
append!( seq1 seq2 -- seq1 )
append-as( seq1 seq2 exemplar -- newseq )
assert-sequence( got expected -- * )
assert-sequence=( a b -- )
binary-reduce( seq start quot: ( elt1 elt2 -- newelt ) -- value )
bounds-check( n seq -- n seq )
bounds-error( index seq -- * )
but-last( seq -- headseq )
but-last-slice( seq -- slice )
cartesian-each( ... seq1 seq2 quot: ( ... elt1 elt2 -- ... ) -- ... )
cartesian-find( ... seq1 seq2 quot: ( ... elt1 elt2 -- ... ? ) -- ... elt1 elt2 )
cartesian-map( ... seq1 seq2 quot: ( ... elt1 elt2 -- ... newelt ) -- ... newseq )
cartesian-product( seq1 seq2 -- newseq )
cartesian-product-as( seq1 seq2 exemplar -- newseq )
change-nth( ..a i seq quot: ( ..a elt -- ..b newelt ) -- ..b )
check-slice( from to seq -- from to seq )
collapse-slice( m n slice -- m' n' seq )
collector( quot -- quot' vec )
collector-as( quot exemplar -- quot' vec )
concat( seq -- newseq )
concat-as( seq exemplar -- newseq )
copy( src i dst -- )
count( ... seq quot: ( ... elt -- ... ? ) -- ... n )
cut( seq n -- before after )
cut*( seq n -- before after )
cut-slice( seq n -- before-slice after-slice )
cut-slice*( seq n -- before-slice after-slice )
delete-all( seq -- )
delete-slice( from to seq -- )
drop-prefix( seq1 seq2 -- slice1 slice2 )
each( ... seq quot: ( ... x -- ... ) -- ... )
each-from( ... seq quot: ( ... x -- ... ) i -- ... )
each-index( ... seq quot: ( ... elt index -- ... ) -- ... )
empty?( seq -- ? )
exchange( m n seq -- )
filter( ... seq quot: ( ... elt -- ... ? ) -- ... subseq )
filter!( ... seq quot: ( ... elt -- ... ? ) -- ... seq )
filter-as( ... seq quot: ( ... elt -- ... ? ) exemplar -- ... subseq )
find( ... seq quot: ( ... elt -- ... ? ) -- ... i elt )
find-from( ... n seq quot: ( ... elt -- ... ? ) -- ... i elt )
find-index( ... seq quot: ( ... elt i -- ... ? ) -- ... i elt )
find-index-from( ... n seq quot: ( ... elt i -- ... ? ) -- ... i elt )
find-last( ... seq quot: ( ... elt -- ... ? ) -- ... i elt )
find-last-from( ... n seq quot: ( ... elt -- ... ? ) -- ... i elt )
first( seq -- first )
first2( seq -- first second )
first3( seq -- first second third )
first4( seq -- first second third fourth )
flip( matrix -- newmatrix )
follow( ... obj quot: ( ... prev -- ... result/f ) -- ... seq )
fourth( seq -- fourth )
from-tail( seq n -- seq n' )
glue( seq1 seq2 seq3 -- newseq )
glue-as( seq1 seq2 seq3 exemplar -- newseq )
halves( seq -- first-slice second-slice )
harvest( seq -- newseq )
head( seq n -- headseq )
head*( seq n -- headseq )
head-slice( seq n -- slice )
head-slice*( seq n -- slice )
head?( seq begin -- ? )
if-empty( ..a seq quot1: ( ..a -- ..b ) quot2: ( ..a seq -- ..b ) -- ..b )
immutable( element index sequence -- * )
index( obj seq -- n )
index-from( obj i seq -- n )
index-of-last( seq -- n seq )
index-or-length( seq n -- seq n' )
indices( obj seq -- indices )
infimum( seq -- elt )
infimum-by( ... seq quot: ( ... elt -- ... x ) -- ... elt )
insert-nth( elt n seq -- seq' )
interleave( ... seq between quot: ( ... elt -- ... ) -- ... )
join( seq glue -- newseq )
join-as( seq glue exemplar -- newseq )
last( seq -- elt )
last-index( obj seq -- n )
last-index-from( obj i seq -- n )
last2( seq -- penultimate ultimate )
lengthd( seq obj -- n obj )
longer( seq1 seq2 -- seq )
longer?( seq1 seq2 -- ? )
longest( seqs -- elt )
map( ... seq quot: ( ... elt -- ... newelt ) -- ... newseq )
map!( ... seq quot: ( ... elt -- ... newelt ) -- ... seq )
map-as( ... seq quot: ( ... elt -- ... newelt ) exemplar -- ... newseq )
map-find( ... seq quot: ( ... elt -- ... result/f ) -- ... result elt )
map-find-last( ... seq quot: ( ... elt -- ... result/f ) -- ... result elt )
map-index( ... seq quot: ( ... elt index -- ... newelt ) -- ... newseq )
map-index-as( ... seq quot: ( ... elt index -- ... newelt ) exemplar -- ... newseq )
map-integers( ... len quot: ( ... i -- ... elt ) -- ... newseq )
map-integers-as( ... len quot: ( ... i -- ... elt ) exemplar -- ... newseq )
map-integers-from-as( ... from len quot: ( ... i -- ... elt ) exemplar -- ... newseq )
map-reduce( ..a seq map-quot: ( ..a elt -- ..a intermediate ) reduce-quot: ( ..a prev intermediate -- ..a next ) -- ..a result )
map-sum( ... seq quot: ( ... elt -- ... n ) -- ... n )
max-length( seq1 seq2 -- n )
maximum-by( ... seq quot: ( ... elt -- ... x ) -- ... elt )
member-eq?( elt seq -- ? )
member?( elt seq -- ? )
midpoint@( seq -- n )
min-length( seq1 seq2 -- n )
minimum-by( ... seq quot: ( ... elt -- ... x ) -- ... elt )
mismatch( seq1 seq2 -- i )
move( to from seq -- )
new-like( len exemplar quot -- seq )
new-resizable-like( len-exemplar type-exemplar -- newseq )
new-sequence-like( len-exemplar type-exemplar -- newseq )
none?( ... seq quot: ( ... elt -- ... ? ) -- ... ? )
nths( indices seq -- seq' )
nths-of( seq indices -- seq' )
pad-head( seq n elt -- padded )
pad-tail( seq n elt -- padded )
partition( ... seq quot: ( ... elt -- ... ? ) -- ... trueseq falseseq )
pop( seq -- elt )
pop*( seq -- )
prefix( seq elt -- newseq )
prepend( seq1 seq2 -- newseq )
prepend-as( seq1 seq2 exemplar -- newseq )
produce( ..a pred: ( ..a -- ..b ? ) quot: ( ..b -- ..a obj ) -- ..b seq )
produce-as( ..a pred: ( ..a -- ..b ? ) quot: ( ..b -- ..a obj ) exemplar -- ..b seq )
product( seq -- n )
push( elt seq -- )
push-all( src dst -- )
push-either( ..a elt quot: ( ..a elt -- ..b ? ) accum1 accum2 -- ..b )
push-when( ..a elt quot: ( ..a elt -- ..b ? ) accum -- ..b )
reduce( ... seq identity quot: ( ... prev elt -- ... next ) -- ... result )
reduce-index( ... seq identity quot: ( ... prev elt index -- ... next ) -- ... result )
reject( ... seq quot: ( ... elt -- ... ? ) -- ... subseq )
reject!( ... seq quot: ( ... elt -- ... ? ) -- ... seq )
reject-as( ... seq quot: ( ... elt -- ... ? ) exemplar -- ... subseq )
remove( elt seq -- newseq )
remove!( elt seq -- seq )
remove-eq( elt seq -- newseq )
remove-eq!( elt seq -- seq )
remove-nth( n seq -- seq' )
remove-nth!( n seq -- seq )
replace-slice( new from to seq -- seq' )
replicate( ... len quot: ( ... -- ... newelt ) -- ... newseq )
replicate-as( ... len quot: ( ... -- ... newelt ) exemplar -- ... newseq )
rest( seq -- tailseq )
rest-slice( seq -- slice )
reverse( seq -- newseq )
reverse!( seq -- seq )
second( seq -- second )
selector( quot -- selector accum )
selector-as( quot exemplar -- selector accum )
sequence-hashcode( depth seq -- x )
sequence=( seq1 seq2 -- ? )
set-first( first seq -- )
set-fourth( fourth seq -- )
set-last( elt seq -- )
set-second( second seq -- )
set-third( third seq -- )
shorter( seq1 seq2 -- seq )
shorter?( seq1 seq2 -- ? )
shortest( seqs -- elt )
sift( seq -- newseq )
slice-error( from to seq -- * )
snip( from to seq -- head tail )
snip-slice( from to seq -- head tail )
subseq( from to seq -- subseq )
subseq-as( from to seq exemplar -- subseq )
subseq-index( seq subseq -- i/f )
subseq-index-from( n seq subseq -- i/f )
subseq-of?( seq subseq -- ? )
subseq-start( subseq seq -- i/f )
subseq-start-from( subseq seq n -- i/f )
subseq-starts-at?( i seq subseq -- ? )
subseq?( subseq seq -- ? )
suffix( seq elt -- newseq )
suffix!( seq elt -- seq )
supremum( seq -- elt )
supremum-by( ... seq quot: ( ... elt -- ... x ) -- ... elt )
surround( seq1 seq2 seq3 -- newseq )
surround-as( seq1 seq2 seq3 exemplar -- newseq )
tail( seq n -- tailseq )
tail*( seq n -- tailseq )
tail-slice( seq n -- slice )
tail-slice*( seq n -- slice )
tail?( seq end -- ? )
third( seq -- third )
trim( ... seq quot: ( ... elt -- ... ? ) -- ... newseq )
trim-head( ... seq quot: ( ... elt -- ... ? ) -- ... newseq )
trim-head-slice( ... seq quot: ( ... elt -- ... ? ) -- ... slice )
trim-slice( ... seq quot: ( ... elt -- ... ? ) -- ... slice )
trim-tail( ... seq quot: ( ... elt -- ... ? ) -- ... newseq )
trim-tail-slice( ... seq quot: ( ... elt -- ... ? ) -- ... slice )
unclip( seq -- rest first )
unclip-last( seq -- butlast last )
unclip-last-slice( seq -- butlast-slice last )
unclip-slice( seq -- rest-slice first )
unless-empty( ... seq quot: ( ... seq -- ... ) -- ... )
when-empty( ... seq quot: ( ... -- ... obj ) -- ... seq/obj )


Class predicate words
WordStack effect
assert-sequence?( object -- ? )
bounds-error?( object -- ? )
immutable-sequence?( object -- ? )
immutable?( object -- ? )
iota?( object -- ? )
repetition?( object -- ? )
reversed?( object -- ? )
sequence-view?( object -- ? )
sequence?( object -- ? )
slice-error?( object -- ? )
slice?( object -- ? )
virtual-sequence?( object -- ? )
wrapped-sequence?( object -- ? )


Files


Metadata files


Children from resource:basis
VocabularySummary
sequences.complexVirtual sequence wrapper to convert real pairs into complex values
sequences.complex-componentsVirtual sequence wrapper to convert complex values into real value pairs
sequences.cordsVirtual sequence concatenation
sequences.deepSequence/tree combinators like deep-map, deep-each, etc
sequences.generalizations
sequences.mergedA virtual sequence which merges (interleaves) other sequences.
sequences.paddedVirtual "padded" sequences
sequences.productCartesian products of sequences
sequences.unrolledUnrolled fixed-length sequence iteration
sequences.windowed


Children from resource:extra
VocabularySummary
sequences.abbrev
sequences.extrasContains sequence operations that are not commonly needed. Most of these words are elaborations on functions already available in the main sequences vocabulary.
sequences.frozenVirtual "frozen" sequences
sequences.insertersDirect the output of map-as, filter-as, etc. combinators into existing growable sequences
sequences.interleavedInterleaved sequences
sequences.modified
sequences.n-basedSequence adaptor to treat a sequence as an n-based assoc
sequences.parser
sequences.prefixed
sequences.repeating
sequences.rotatedRotated virtual sequences
sequences.seq
sequences.shiftedShifted virtual sequences
sequences.snippedSnipped virtual sequences
sequences.squishSequence flattening with parameterized descent predicate
sequences.suffixed
sequences.zippedVirtual "zip" sequences