Skip to content

Commit cdeac5b

Browse files
committed
#50 Update README
1 parent 442500c commit cdeac5b

File tree

1 file changed

+21
-1
lines changed

1 file changed

+21
-1
lines changed

README.rst

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -261,6 +261,26 @@ see also, typesafe implementations: FilterInt_, FilterInt64_, FilterFloat32_, Fi
261261
.. _FilterInt64: https://godoc.org/github.com/thoas/go-funk#FilterInt64
262262
.. _FilterString: https://godoc.org/github.com/thoas/go-funk#FilterString
263263

264+
funk.Reduce
265+
...........
266+
267+
Reduces an iteratee based on an accumulator function or operation rune for numbers.
268+
269+
.. code-block:: go
270+
271+
// Using operation runes. '+' and '*' only supported.
272+
r := funk.Reduce([]int{1, 2, 3, 4}, '+', float64(0)) // 10
273+
r := funk.Reduce([]int{1, 2, 3, 4}, '*', 1) // 24
274+
275+
// Using accumulator function
276+
r := funk.Reduce([]int{1, 2, 3, 4}, func(acc float64, num int) float64 {
277+
return acc + float64(num)
278+
}, float64(0)) // 10
279+
280+
r := funk.Reduce([]int{1, 2, 3, 4}, func(acc string, num int) string {
281+
return acc + fmt.Sprint(num)
282+
}, "") // "1234"
283+
264284
funk.Find
265285
.........
266286

@@ -318,7 +338,7 @@ Manipulates an iteratee (map, slice) and transforms it to another type:
318338
}) // map[string]string{"1": "Florent", "2": "Gilles"}
319339
320340
funk.FlatMap
321-
........
341+
............
322342

323343
Manipulates an iteratee (map, slice) and transforms it to to a flattened collection of another type:
324344

0 commit comments

Comments
 (0)