JanetDocsI'm feeling luckyGitHub sign in

reduce



    function
    boot.janet on line 841, column 1

    (reduce f init ind)

    Reduce, also know as fold-left in many languages, transforms an
    indexed type (array, tuple) with a function to produce a value by
    applying f to each element in order. f is a function of 2 arguments,
    (f accum el), where accum is the initial value and el is the next
    value in the indexed type ind. f returns a value that will be used as
    accum in the next call to f. reduce returns the value of the final
    call to f.


See also:accumulatereduce21 exampleSign in to add an example
Loading...
(reduce (fn [s1 s2]
          (string "[" s1 "+" s2 "]"))
        "x"
        ["a" "b" "c"])

#=> "[[[x+a]+b]+c]"
uvtc