You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
PR #566 introduced Product() but I believe its return value for an empty slice is incorrect: it currently returns 0 but it should be 1.
Operations such as Sum() and Product() are so-called fold operations with the initial value mathematically called identity element. Normally, the identity element of product operation is 1, so Product(<empty slice>) should return 1 (not 0).
PR #566 introduced
Product()
but I believe its return value for an empty slice is incorrect: it currently returns0
but it should be1
.Operations such as
Sum()
andProduct()
are so-called fold operations with the initial value mathematically called identity element. Normally, the identity element of product operation is1
, soProduct(<empty slice>)
should return1
(not0
).Supporting evidence:
Empty product - Wikipedia and Fold (higher-order function) - Wikipedia say the value of empty product is
1
.Rust's
Iterator::product()
returns1
for an empty slice.Haskell's
product
returns1
for an empty list.The text was updated successfully, but these errors were encountered: