Searching sequences
Factor handbook » The language » Collections » Sequence operations

Prev:Testing sequences
Next:Comparing sequences


Finding the index of an element:
index ( obj seq -- n )

index-from ( obj i seq -- n )

last-index ( obj seq -- n )

last-index-from ( obj i seq -- n )


Finding the start of a subsequence:
subseq-start ( subseq seq -- i/f )

subseq-start-from ( subseq seq n -- i/f )

subseq-index ( seq subseq -- i/f )

subseq-index-from ( n seq subseq -- i/f )

subseq-starts-at? ( i seq subseq -- ? )


Finding the index of an element satisfying a predicate:
find ( ... seq quot: ( ... elt -- ... ? ) -- ... i elt )

find-from ( ... n seq quot: ( ... elt -- ... ? ) -- ... i elt )

find-last ( ... seq quot: ( ... elt -- ... ? ) -- ... i elt )

find-last-from ( ... n seq quot: ( ... elt -- ... ? ) -- ... i elt )

map-find ( ... seq quot: ( ... elt -- ... result/f ) -- ... result elt )