From de68e712e9bb839780e9c006dab9a3067aafac17 Mon Sep 17 00:00:00 2001 From: Doug Coleman Date: Wed, 17 Sep 2008 09:43:18 -0500 Subject: [PATCH] more docs --- core/sequences/sequences-docs.factor | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/core/sequences/sequences-docs.factor b/core/sequences/sequences-docs.factor index cd16c99361..f9c539f16a 100755 --- a/core/sequences/sequences-docs.factor +++ b/core/sequences/sequences-docs.factor @@ -40,6 +40,18 @@ $nl "Throws an error if the sequence cannot hold elements of the given type." } { $side-effects "seq" } ; +HELP: nths +{ $values + { "indices" null } { "seq" sequence } + { "seq'" sequence } } +{ $description "Ouptuts a sequence of elements from the input sequence indexed by the indices." } +{ $examples + { $example "USING: prettyprint sequences ;" + "{ 0 2 } { \"a\" \"b\" \"c\" } nths ." + "{ \"a\" \"c\" }" + } +} ; + HELP: immutable { $values { "seq" sequence } } { $description "Throws an " { $link immutable } " error." } @@ -249,6 +261,15 @@ HELP: reduce { $example "USING: math prettyprint sequences ;" "{ 1 5 3 } 0 [ + ] reduce ." "9" } } ; +HELP: reduce-index +{ $values + { "seq" sequence } { "identity" object } { "quot" quotation } } +{ $description "Combines successive elements of the sequence and their indices using a binary operation, and outputs the final result. On the first iteration, the two inputs to the quotation are " { $snippet "identity" } ", the first element of the sequence, and its index, 0. On successive iterations, the first input is the result of the previous iteration, the second input is the corresponding element of the sequence, and the third is its index." } +{ $examples { $example "USING: sequences prettyprint math ;" + "{ 10 50 90 } 0 [ + + ] reduce-index ." + "153" +} } ; + HELP: accumulate { $values { "identity" object } { "seq" sequence } { "quot" "a quotation with stack effect " { $snippet "( prev elt -- next )" } } { "final" "the final result" } { "newseq" "a new sequence" } } { $description "Combines successive elements of the sequence using a binary operation, and outputs a sequence of intermediate results together with the final result. On the first iteration, the two inputs to the quotation are " { $snippet "identity" } ", and the first element of the sequence. On successive iterations, the first input is the result of the previous iteration, and the second input is the corresponding element of the sequence."