The Order of Filtering and Mapping
Filtering before a transformation asks about original values. Filtering afterward asks about transformed values.
- Source
- Anbloq
- Language
- English
- Created
- Updated
- Chapters
- 2
- Reading time
- 1 min
In this article2 chapters
Trace a sign example
On minus 3, 1, and 2, filtering positive numbers before squaring gives 1 and 4. Squaring first and then keeping positives gives 9, 1, and 4. Function composition order governs which value enters the predicate.
State which stage owns validity
A syntactic check may need original text, while a range check needs its parsed numeric value. Validation by stages clarifies which ordering expresses the rule.[1]