Skip to content

reduce

reduce<A, B>(init, f): <K>(m) => B

Defined in: Utils/Dict.ts:409

Folds the dictionary into a single value by applying f to each value in insertion order. When you also need the key, use reduceWithKey.

A

B

B

(acc, value) => B

<K>(m): B

K

ReadonlyMap<K, A>

B

Dict.reduce(0, (acc, value) => acc + value)(
  Dict.fromEntries([["a", 1], ["b", 2], ["c", 3]])
); // 6