Skip to content

Product() of empty slice should be 1 (not 0). #583

@your-diary

Description

@your-diary

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).

Supporting evidence:

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions