+}
+{ $notes "May be named " { $snippet "scan" } " or " { $snippet "prefix sum" } " in other languages." } ;
+
+HELP: accumulate*-as
+{ $values { "seq" sequence } { "identity" object } { "quot" { $quotation ( ... prev elt -- ... next ) } } { "exemplar" sequence } { "newseq" "a new sequence" } }
+{ $description "Combines successive elements of the sequence using a binary operation, and outputs a sequence of the same type as " { $snippet "exemplar" } " containing all results."
+$nl
+"On the first iteration, the two inputs to the quotation are " { $snippet "identity" } " and the first element of the input sequence. On successive iterations, the first input is the result of the previous iteration, and the second input is the next element of the input sequence."
+$nl
+"When given the empty sequence, outputs a new empty sequence" }
+{ $notes "May be named " { $snippet "scan" } " or " { $snippet "prefix sum" } " in other languages." } ;
+
+HELP: accumulate*
+{ $values { "seq" sequence } { "identity" object } { "quot" { $quotation ( ... prev elt -- ... next ) } } { "newseq" sequence } }
+{ $description "Combines successive elements of the sequence using a binary operation, and outputs a sequence of all results."
+$nl
+"On the first iteration, the two inputs to the quotation are " { $snippet "identity" } " and the first element of the input sequence. On successive iterations, the first input is the result of the previous iteration, and the second input is the next element of the input sequence."
+$nl
+"When given the empty sequence, outputs a new empty sequence." }
+{ $examples
+ { $example "USING: math prettyprint sequences ;" "{ 2 2 2 2 2 } 0 [ + ] accumulate* ." "{ 2 4 6 8 10 }" }
+}
+{ $notes "May be named " { $snippet "scan" } " or " { $snippet "prefix sum" } " in other languages." } ;
+
+HELP: accumulate*!
+{ $values { "seq" sequence } { "identity" object } { "quot" { $quotation ( ... prev elt -- ... next ) } } }
+{ $description "Combines successive elements of the sequence using a binary operation, and outputs the original sequence of all results."
+$nl
+"On the first iteration, the two inputs to the quotation are " { $snippet "identity" } " and the first element of the input sequence. On successive iterations, the first input is the result of the previous iteration, and the second input is the next element of the input sequence."
+$nl
+"When given the empty sequence, outputs the same empty sequence." }
+{ $errors "Throws an error if the sequence is immutable, or the sequence cannot hold elements of the type output by " { $snippet "quot" } "." }
+{ $side-effects "seq" }
+{ $examples
+ { $example "USING: math prettyprint sequences ;" "{ 2 2 2 2 2 } 0 [ + ] accumulate*! ." "{ 2 4 6 8 10 }" }
+}
+{ $notes "May be named " { $snippet "scan" } " or " { $snippet "prefix sum" } " in other languages." } ;
+
+{ accumulate accumulate! accumulate-as accumulate* accumulate*! accumulate*-as } related-words