]> gitweb.factorcode.org Git - factor.git/blobdiff - core/sequences/sequences-docs.factor
assocs: Add zip-index, zip-index-as and docs/tests.
[factor.git] / core / sequences / sequences-docs.factor
index 80ec15cfbfeb2821b846f96631edba62d3b4953e..1e85d4efeb6fdc3c3c25183977c7db2387395dd4 100644 (file)
@@ -374,6 +374,16 @@ HELP: map-index
 "{ { 10 0 } { 20 1 } { 30 2 } }"
 } } ;
 
+HELP: map-index-as
+{ $values
+  { "seq" sequence } { "quot" { $quotation ( ... elt index -- ... newelt ) } } { "exemplar" sequence } { "newseq" sequence } }
+{ $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 " { $snippet "exemplar" } " sequence." }
+{ $examples { $example "USING: arrays sequences prettyprint ;"
+"{ 10 20 30 } [ 2array ] V{ } map-index-as ."
+"V{ { 10 0 } { 20 1 } { 30 2 } }"
+} } ;
+{ map-index map-index-as } related-words
+
 HELP: change-nth
 { $values { "i" "a non-negative integer" } { "seq" "a mutable sequence" } { "quot" { $quotation ( ..a elt -- ..b newelt ) } } }
 { $description "Applies the quotation to the " { $snippet "i" } "th element of the sequence, storing the result back into the sequence." }
@@ -1681,6 +1691,7 @@ ARTICLE: "sequences-combinators" "Sequence combinators"
     map
     map-as
     map-index
+    map-index-as
     map-reduce
     accumulate
     accumulate-as