JanetDocsPlaygroundI'm feeling luckyGitHub sign in

accumulate



    function
    boot.janet on line 892, column 1

    (accumulate f init ind)

    Similar to `reduce`, but accumulates intermediate values into an 
    array. The last element in the array is what would be the return 
    value from `reduce`. The `init` value is not added to the array 
    (the return value will have the same number of elements as `ind`). 
    Returns a new array.


See also:reduce2 examplesSign in to add an example
Loading...
(reduce string "ha" ["ha" "ha" "ha" "ha"]) # => "hahahahaha"

(accumulate string "ha" ["ha" "ha" "ha" "ha"]) # => @["haha" "hahaha" "hahahaha" "hahahahaha"]
jgartePlayground
(reduce     + 1 [2 3 4])  # -> 10
(accumulate + 1 [2 3 4])  # -> @[3 6 10]
cellularmitosisPlayground