 ARTICLE: "sequences-combinators" "Sequence combinators"
 "Iteration:"
 { $subsection each }
+{ $subsection each-index }
 { $subsection reduce }
 { $subsection interleave }
 { $subsection replicate }

"Mapping:"
{ $subsection map }
{ $subsection map-as }
{ $subsection accumulate }
{ $subsection produce }
"Filtering:"

    "Note that " { $link map } " could not be used here, because it would create another string to hold results, and one-element strings cannot themselves be elements of strings."
} ;

HELP: each-index
{ $values
     { "seq" sequence } { "quot" quotation } }
{ $description "Calls the quotation with the element of the sequence and its index on the stack, with the index on the top of the stack." }
{ $examples { $example "USING: sequences prettyprint math ;"
"{ 10 20 30 } [ + . ] each-index"
"10\n21\n32"
} } ;

HELP: map-index
{ $values
     { "seq" sequence } { "quot" quotation } }
{ $description "Calls the quotation with the element of the sequence and its index on the stack, with the index on the top of the stack. Collects the outputs of the quotation and outputs them in a sequence of the same type as the input sequence." }
{ $examples { $example "USING: sequences prettyprint math ;"
"{ 10 20 30 } [ + ] map-index ."
"{ 10 21 32 }"
} } ;

HELP: change-nth
{ $values { "i" "a non-negative integer" } { "seq" "a mutable sequence" } { "quot" "a quotation with stack effect " { $snippet "( elt -- newelt )" } } }
{ $description "Applies the quotation to the " { $snippet "i" } "th element of the sequence, storing the result back into the sequence." }
