min/max operators (#1992)

* min/max operators

* min, max operator headers
This commit is contained in:
Matt Benson
2024-03-30 13:34:36 +11:00
committed by GitHub
parent 3283c65dc4
commit 101cf14b8c
8 changed files with 209 additions and 0 deletions
+3
View File
@@ -0,0 +1,3 @@
# Max
Computes the maximum among an incoming sequence of scalar values.
+3
View File
@@ -0,0 +1,3 @@
# Min
Computes the minimum among an incoming sequence of scalar values.
+48
View File
@@ -0,0 +1,48 @@
## Maximum int
Given a sample.yml file of:
```yaml
- 99
- 16
- 12
- 6
- 66
```
then
```bash
yq 'max' sample.yml
```
will output
```yaml
99
```
## Maximum string
Given a sample.yml file of:
```yaml
- foo
- bar
- baz
```
then
```bash
yq 'max' sample.yml
```
will output
```yaml
foo
```
## Maximum of empty
Given a sample.yml file of:
```yaml
[]
```
then
```bash
yq 'max' sample.yml
```
will output
```yaml
```
+48
View File
@@ -0,0 +1,48 @@
## Minimum int
Given a sample.yml file of:
```yaml
- 99
- 16
- 12
- 6
- 66
```
then
```bash
yq 'min' sample.yml
```
will output
```yaml
6
```
## Minimum string
Given a sample.yml file of:
```yaml
- foo
- bar
- baz
```
then
```bash
yq 'min' sample.yml
```
will output
```yaml
bar
```
## Minimum of empty
Given a sample.yml file of:
```yaml
[]
```
then
```bash
yq 'min' sample.yml
```
will output
```yaml
```