Properties of folds
- Dominant language
- C++
- Stars
- 1.9k
- Forks
- 225
- PR merge metrics
- No merged PRs in 30d
Description
This is an old note I left myself. I was wondering whether we should require that `xs == ys` implies `fold_left(xs, state, f) == fold_left(ys, state, f)`. From a mathematical perspective, this would be the same as requesting that `fold_left` is a mathematical function, which makes sense. But for sets, which are currently foldable, this wouldn't be satisfied unless `f` satisfies some strong condition (namely that we can fold with it in any order and it's going to give the same result).
This applies equally to `fold_left` and `fold_right`.
Contributor guide
Research direction
Start by examining the fold_left and fold_right entry points and how sets are treated as foldable. Determine whether the proposed equality property should be required, including the ordering implications for the folding function, and define the expected behavior before making any change.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- cpp
- Domain
- backend-api-design
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 20/100