sequence
Factor documentation > Factor handbook > The language > Collections > Sequence operations > Sequence protocol
Next:sequence? ( object -- ? )


Vocabulary
sequences

Class description
A mixin class whose instances are sequences. Custom implementations of the sequence protocol should be declared as instances of this mixin for all sequence functionality to work correctly:
INSTANCE: my-sequence sequence


Definition
USING: arrays benchmark.tuple-arrays bit-arrays byte-arrays
game.input.dinput.keys-array game.models.util grouping
grouping.private growable math.blas.matrices math.vectors.simd
nibble-arrays sequences.complex sequences.complex-components
sequences.product specialized-arrays strings xml.data ;

IN: sequences

MIXIN: sequence
INSTANCE: immutable-sequence sequence
INSTANCE: virtual-sequence sequence
INSTANCE: array sequence
INSTANCE: growable sequence
INSTANCE: byte-array sequence
INSTANCE: string sequence
INSTANCE: chunking sequence
INSTANCE: subseq-chunking sequence
INSTANCE: slice-chunking sequence
INSTANCE: abstract-groups sequence
INSTANCE: abstract-clumps sequence
INSTANCE: sliced-circular-clumps sequence
INSTANCE: circular-clumps sequence
INSTANCE: specialized-array sequence
INSTANCE: bit-array sequence
INSTANCE: tag sequence
INSTANCE: xml sequence
INSTANCE: xml-chunk sequence
INSTANCE: keys-array sequence
INSTANCE: blas-matrix-rowcol-sequence sequence
INSTANCE: product-sequence sequence
INSTANCE: char-16 sequence
INSTANCE: uchar-16 sequence
INSTANCE: short-8 sequence
INSTANCE: ushort-8 sequence
INSTANCE: int-4 sequence
INSTANCE: uint-4 sequence
INSTANCE: longlong-2 sequence
INSTANCE: ulonglong-2 sequence
INSTANCE: float-4 sequence
INSTANCE: double-2 sequence
INSTANCE: nibble-array sequence
INSTANCE: complex-sequence sequence
INSTANCE: complex-components sequence
INSTANCE: point-array sequence
INSTANCE: indexed-seq sequence


Methods
USING: bootstrap.image.private kernel sequences ;

M: sequence (eql?)
2dup [ length ] bi@ = [ [ eql? ] 2all? ] [ 2drop f ] if ;


USING: assocs http.client.post-data.private kernel sequences ;

M: sequence (set-post-data-headers)
length "content-length" pick set-at ;


USING: http.client.post-data.private io sequences ;

M: sequence (write-post-data) write ;


USING: kernel math.order sequences sequences.private ;

M: sequence <=>
[ mismatch ] 2keep pick
[ 2nth-unsafe <=> ] [ [ length ] compare nip ] if ;


USING: accessors kernel mongodb.msg sequences ;

M: sequence <mdb-insert-msg>
[ mdb-insert-msg new ] 2dip [ >>collection ] dip >>objects
OP_Insert >>opcode ;


USING: accessors kernel mongodb.msg sequences ;

M: sequence <mdb-killcursors-msg>
[ mdb-killcursors-msg new ] dip [ length >>cursors# ] keep
>>cursors OP_KillCursors >>opcode ; inline


USING: io.pipes.private math sequences ;

M: sequence <pipes> [ { } ] [ length 1 - <pipes> ] if-empty ;


USING: assocs sequences ;

M: sequence >alist ; inline


USING: combinators kernel sequences xml.syntax.inverse ;

M: sequence [undo-xml]
remove-blanks [ length ] [ [ [undo-xml] ] { } map-as ] bi [
[ [ remove-blanks ] ] dip [ firstn-strong ] curry
compose
] dip [ spread ] curry compose ;


USING: kernel sequences sets ;

M: sequence adjoin [ delete ] [ push ] 2bi ;


USING: hash-sets hash-sets.private hashtables kernel sequences
sets ;

M: sequence all-unique?
dup length <hashtable> hash-set boa [ (all-unique?) ] curry
all? ;


USING: assocs kernel sequences ;

M: sequence assoc-clone-like [ >alist ] dip clone-like ; inline


USING: assocs kernel sequences ;

M: sequence assoc-like [ >alist ] dip like ; inline


USING: assocs sequences ;

M: sequence assoc-size length ; inline


USING: compiler.tree.propagation.constraints sequences ;

M: sequence assume* [ assume ] each ;


USING: assocs assocs.private kernel sequences ;

M: sequence at* search-alist [ second t ] [ f ] if ;


USING: cursors sequences ;

M: sequence begin-cursor 0 <sequence-cursor> ; inline


USING: combinators cuda.libraries.private kernel sequences ;

M: sequence block-dim
dup length {
{ 0 [ drop 1 1 1 ] }
{ 1 [ first 1 1 ] }
{ 2 [ first2 1 ] }
[ drop first3 ]
} case ; inline


USING: kernel sequences sequences.deep ;

M: sequence branch? drop t ;


USING: irc.client.internals kernel sequences ;

M: sequence chat-put [ chat-put ] with each ;


USING: assocs sequences ;

M: sequence clear-assoc delete-all ; inline


USING: kernel sequences ;

M: sequence clone-like
[ dup length ] dip new-sequence [ 0 swap copy ] keep ;
inline


USING: kernel sequences sets ;

M: sequence delete remove! drop ; inline


USING: assocs assocs.private kernel sequences ;

M: sequence delete-at
[ nip ] [ search-alist nip ] 2bi
[ swap remove-nth! drop ] [ drop ] if* ;


USING: kernel sequences sets ;

M: sequence duplicates
f fast-set [ [ in? ] [ adjoin ] 2bi ] curry filter ;


USING: cursors kernel sequences ;

M: sequence end-cursor dup length <sequence-cursor> ; inline


USING: hash-sets sequences sets ;

M: sequence fast-set <hash-set> ;


USING: fuel.pprint fuel.pprint.private sequences ;

M: sequence fuel-pprint "(" ")" fuel-pprint-sequence ; inline


USING: benchmark.dispatch3 kernel sequences ;

M: sequence g drop "sequence" ;


USING: combinators cuda.libraries.private kernel sequences ;

M: sequence grid-dim
dup length
{ { 0 [ drop 1 1 ] } { 1 [ first 1 ] } [ drop first2 ] }
case ; inline


USING: combinators kernel sequences ;

M: sequence hashcode*
[ sequence-hashcode ] recursive-hashcode ;


USING: classes sequences sets ;

M: sequence implementors [ implementors ] gather ;


USING: sequences sets ;

M: sequence in? member? ; inline


USING: io json.writer sequences ;

M: sequence json-print
91 write1 [ >json ] map "," join write 93 write1 ;


USING: kernel math sequences ;

M: sequence lengthen
2dup length > [ set-length ] [ 2drop ] if ; inline


USING: kernel sequences ;

M: sequence like drop ; inline


USING: kernel sequences sets sets.private ;

M: sequence members [ pruned ] keep like ;


USING: assocs kernel sequences vectors ;

M: sequence new-assoc drop <vector> ; inline


USING: kernel persistent.sequences sequences ;

M: sequence new-nth clone [ set-nth ] keep ;


USING: kernel sequences vectors ;

M: sequence new-resizable drop <vector> ; inline


USING: sequences sequences.private ;

M: sequence nth bounds-check nth-unsafe ; inline


USING: sequences sequences.private ;

M: sequence nth-unsafe nth ; inline


USING: sequences sets ;

M: sequence null? empty? ; inline


USING: persistent.sequences sequences ;

M: sequence ppop 1 head* ;


USING: kernel persistent.sequences sequences ;

M: sequence ppush swap suffix ;


USING: kernel make sequences xml.data xml.syntax.private ;

M: sequence push-item
dup xml-data? [ , ] [ [ push-item ] each ] if ;


USING: kernel random random.private sequences ;

M: sequence random
[ f ] [ [ length random-integer ] keep nth ] if-empty ;


USING: boyer-moore boyer-moore.private kernel math sequences ;

M: sequence search-from
dup length zero?
[ 3drop 0 ] [ <boyer-moore> (search-from) ] if ;


USING: sequences smalltalk.selectors ;

M: sequence selector-at: nth ;


USING: kernel sequences smalltalk.selectors ;

M: sequence selector-at:put: [ swapd set-nth ] keep ;


USING: arrays assocs assocs.private kernel sequences ;

M: sequence set-at
2dup search-alist
[ 2nip set-second ] [ drop [ swap 2array ] dip push ] if ;


USING: kernel sequences sets ;

M: sequence set-like [ members ] dip like ;


USING: sequences sequences.private ;

M: sequence set-nth bounds-check set-nth-unsafe ; inline


USING: sequences sequences.private ;

M: sequence set-nth-unsafe set-nth ; inline


USING: kernel math sequences ;

M: sequence shorten
2dup length < [ set-length ] [ 2drop ] if ; inline


USING: alien.strings sequences ;

M: sequence string>symbol [ string>symbol* ] map ;


USING: accessors classes kernel make math.parser sequences
summary ;

M: sequence summary
[ dup class name>> % " with " % length # " elements" % ] ""
make ;


USING: classes classes.private generic kernel sequences ;

M: sequence update-methods
implementors [ update-generic ] with each ;


USING: db.queries kernel nmake sequences ;

M: sequence where
[ [ " or " 0% ] [ dupd where ] interleave drop ] in-parens
;


USING: sequences xml.writer ;

M: sequence write-xml [ write-xml ] each ;