sequences vocabulary
Factor handbook > Vocabulary index


Documentation
Sequence operations

Meta-data
Tags:collections
Authors:Slava Pestov


Words

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


Mixin classes
immutable-sequence
sequence
virtual-sequence


Generic words
WordStack effect
bounds-check?( n seq -- ? )
clone-like( seq exemplar -- newseq )
length( seq -- n )
lengthen( n seq -- )
like( seq exemplar -- newseq )
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 )
2all?( ... seq1 seq2 quot: ( ... elt1 elt2 -- ... ? ) -- ... ? )
2each( ... seq1 seq2 quot: ( ... elt1 elt2 -- ... ) -- ... )
2each-from( ... seq1 seq2 quot: ( ... elt1 elt2 -- ... ) i -- ... )
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 -- ..b intermediate ) reduce-quot: ( ..b 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 -- ... ) -- ... )
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 )
<repetition>( len elt -- repetition )
<reversed>( seq -- reversed )
<slice>( from to seq -- slice )
?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-map( ... seq1 seq2 quot: ( ... elt1 elt2 -- ... newelt ) -- ... newseq )
cartesian-product( seq1 seq2 -- 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 )
collector-for( seq quot -- seq quot' vec )
collector-for-as( seq quot exemplar -- seq 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 )
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 )
glue( seq1 seq2 seq3 -- 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 )
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 -- ... ) -- ... )
iota( n -- iota )
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 )
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 ) exemplar -- ... newseq )
map-reduce( ..a seq map-quot: ( ..a elt -- ..b intermediate ) reduce-quot: ( ..b prev intermediate -- ..a next ) -- ..a result )
map-sum( ... seq quot: ( ... elt -- ... n ) -- ... n )
max-length( seq1 seq2 -- n )
member-eq?( elt seq -- ? )
member?( elt seq -- ? )
midpoint@( seq -- n )
min-length( seq1 seq2 -- n )
mismatch( seq1 seq2 -- i )
move( to from seq -- )
new-like( len exemplar quot -- seq )
non-negative-integer-expected( n -- * )
nths( indices seq -- seq' )
pad-head( seq n elt -- padded )
pad-tail( seq n elt -- padded )
padding( ... seq n elt quot: ( ... seq1 seq2 -- ... newseq ) -- ... newseq )
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-if( ..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( n 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 -- )
short( seq n -- seq n' )
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 )
start( subseq seq -- i )
start*( subseq seq n -- i )
subseq( from to seq -- subseq )
subseq-as( from to seq exemplar -- 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 )
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 -- )
when-empty( seq quot -- )


Class predicate words
WordStack effect
assert-sequence?( object -- ? )
bounds-error?( object -- ? )
immutable-sequence?( object -- ? )
immutable?( object -- ? )
iota-tuple?( object -- ? )
non-negative-integer-expected?( object -- ? )
repetition?( object -- ? )
reversed?( object -- ? )
sequence?( object -- ? )
slice-error?( object -- ? )
slice?( object -- ? )
virtual-sequence?( object -- ? )


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.generalizationssequences.generalizations vocabulary
sequences.mergedA virtual sequence which merges (interleaves) other sequences.
sequences.parsersequences.parser vocabulary
sequences.productCartesian products of sequences
sequences.unrolledUnrolled fixed-length sequence iteration
sequences.windowedsequences.windowed vocabulary


Children from resource:extra
VocabularySummary
sequences.abbrevsequences.abbrev vocabulary
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.modifiedsequences.modified vocabulary
sequences.n-basedSequence adaptor to treat a sequence as an n-based assoc
sequences.repeatingsequences.repeating vocabulary
sequences.rotatedRotated virtual sequences
sequences.shiftedShifted virtual sequences
sequences.snippedSnipped virtual sequences
sequences.squishSequence flattening with parameterized descent predicate
sequences.zippedVirtual "zip" sequences


Children
VocabularySummary
sequences.privatesequences.private vocabulary