diff options
| author | Bruce Hill <bruce@bruce-hill.com> | 2025-04-06 14:52:59 -0400 |
|---|---|---|
| committer | Bruce Hill <bruce@bruce-hill.com> | 2025-04-06 14:52:59 -0400 |
| commit | 4043a99e0df9fab6791c485721c0046971754175 (patch) | |
| tree | 5e9c966ecf315be98bd292d6d39511d6c0447ee5 /docs | |
| parent | 2bb2ff871fa1761478442bec5f6a32c9428360a1 (diff) | |
Expand reducers so they support stuff like `(+.abs(): nums)` and
`(==.length: texts)`
Diffstat (limited to 'docs')
| -rw-r--r-- | docs/reductions.md | 24 |
1 files changed, 20 insertions, 4 deletions
diff --git a/docs/reductions.md b/docs/reductions.md index 7aadd30b..3cbb6d5d 100644 --- a/docs/reductions.md +++ b/docs/reductions.md @@ -69,10 +69,10 @@ a collection using the `_min_` and `_max_` infix operators. = 10 ``` -The `_min_` and `_max_` operators also support field and method call suffixes, -which makes it very easy to compute the argmin/argmax (or keyed -minimum/maximum) of a collection. This is when you want to get the minimum or -maximum value _according to some feature_. +Reducers also support field and method call suffixes, which makes it very easy +to compute the argmin/argmax (or keyed minimum/maximum) of a collection. This +is when you want to get the minimum or maximum value _according to some +feature_. ```tomo # Get the longest text: @@ -84,6 +84,22 @@ maximum value _according to some feature_. = -4 ``` +You can also use suffixes on other operators: + +```tomo +texts := ["x", "y", "z"] +>> (==: texts) += no +>> (==.length: texts) += yes +>> (+.length: texts) += 3 + +nums := [1, 2, -3] +>> (+.abs(): nums) += 6 +``` + ## Comprehensions Reductions work not only with iterable values (arrays, sets, integers, etc.), |
