Choosing an Identity for a Fold

An identity leaves an operand unchanged when combined with it. It often supplies a useful meaning for folding an empty collection.

Source
Anbloq
Language
English
Created
Updated
Chapters
2
Reading time
1 min
In this article2 chapters
  1. Compare addition and multiplication
  2. Check where no identity is available

Compare addition and multiplication

The additive identity is zero and the multiplicative identity is one. Starting a product with zero would erase every later input. This is a specific consequence of accumulator initialization.

Check where no identity is available

A maximum over a domain of all integers lacks a smallest integer identity in that domain. A missing state or required first element can express the needed rule. Compare running minima for the corresponding lower-bound case.[1]

References

  1. Python Software Foundation, Functional Programming HOWTO ↩