diff --git a/core/sequences/sequences-docs.factor b/core/sequences/sequences-docs.factor index 8d6ddf1be9..f7f774ad86 100644 --- a/core/sequences/sequences-docs.factor +++ b/core/sequences/sequences-docs.factor @@ -286,7 +286,7 @@ $nl HELP: accumulate { $values { "seq" sequence } { "identity" object } { "quot" { $quotation "( ... prev elt -- ... next )" } } { "final" "the final result" } { "newseq" "a new array" } } -{ $description "Combines successive elements of the sequence using a binary operation, and outputs an array of intermediate results, together with the final result." +{ $description "Combines successive elements of the sequence using a binary operation, and outputs a sequence of intermediate results, together with the final result." $nl "The first element of the new sequence is " { $snippet "identity" } ". Then, on the first iteration, the two inputs to the quotation are " { $snippet "identity" } ", and the first element of the old sequence. On successive iterations, the first input is the result of the previous iteration, and the second input is the corresponding element of the old sequence." $nl diff --git a/core/sequences/sequences-tests.factor b/core/sequences/sequences-tests.factor index 665e7a7ada..175ab252e1 100644 --- a/core/sequences/sequences-tests.factor +++ b/core/sequences/sequences-tests.factor @@ -24,6 +24,9 @@ IN: sequences.tests [ 5040 { 1 1 2 6 24 120 720 } ] [ { 1 2 3 4 5 6 7 } 1 [ * ] accumulate ] unit-test +[ 64 B{ 1 2 4 16 } ] +[ B{ 2 2 4 4 } 1 [ * ] accumulate ] unit-test + [ 5040 { 1 1 2 6 24 120 720 } ] [ { 1 2 3 4 5 6 7 } 1 [ * ] accumulate! ] unit-test diff --git a/core/sequences/sequences.factor b/core/sequences/sequences.factor index 02c5d0ac72..d9c234e717 100644 --- a/core/sequences/sequences.factor +++ b/core/sequences/sequences.factor @@ -436,7 +436,7 @@ PRIVATE> [ (accumulate) ] dip map-as ; inline : accumulate ( ... seq identity quot: ( ... prev elt -- ... next ) -- ... final newseq ) - { } accumulate-as ; inline + pick accumulate-as ; inline : accumulate! ( ... seq identity quot: ( ... prev elt -- ... next ) -- ... final seq ) (accumulate) map! ; inline