Files
lo/docs/data/it-product.md
T
Samuel Berthe fa095e4b4f fix(doc): fix go playground demo URL (#832)
* fix(doc): fix go playground demo URL

* fix(doc): add more go playground demo URL
2026-03-06 00:09:59 +01:00

881 B

name, slug, sourceRef, category, subCategory, signatures, playUrl, variantHelpers, similarHelpers, position
name slug sourceRef category subCategory signatures playUrl variantHelpers similarHelpers position
Product / ProductBy product it/math.go#L70 it math
func Product[T constraints.Float | constraints.Integer | constraints.Complex](collection iter.Seq[T]) T
func ProductBy[T any, R constraints.Float | constraints.Integer | constraints.Complex](collection iter.Seq[T], iteratee func(item T) R) R
https://go.dev/play/p/AOMCD1Yl5Bc
it#math#product
it#math#productby
core#slice#product
core#slice#productby
20

Multiplies values from a sequence. ProductBy applies a transform then multiplies. Returns 1 for empty sequences.

Examples:

seq := it.RangeFrom(1, 4) // 1,2,3,4
p := it.Product(seq)
// p == 24
nums := it.RangeFrom(2, 3) // 2,3,4
p := it.ProductBy(nums, func(n int) int { return n - 1 })
// (1*2*3) == 6