catala/tests/test_array/good/aggregation.catala_en

53 lines
1.3 KiB
Plaintext

## Article
```catala
declaration scope A:
output x content collection money
scope A:
definition x equals [$0; $4 + $5; $8 * 0.65]
declaration scope B:
a scope A
output max content money
output min content money
output y content money
output z content integer
scope B:
definition max equals maximum of (m * 2.0) for m among a.x
or if collection empty then $0
definition min equals minimum of (m + $5) for m among a.x
or if collection empty then $20
definition y equals sum money of (m + $1) for m among a.x
definition z equals number of m among a.x such that m >= $8.95
```
```catala-test-inline
$ catala Interpret -s A
[RESULT] Computation successful! Results:
[RESULT] x = [ $0.00; $9.00; $5.20 ]
```
```catala-test-inline
$ catala Interpret -s B
[RESULT] Computation successful! Results:
[RESULT] max = $18.00
[RESULT] min = $5.00
[RESULT] y = $17.20
[RESULT] z = 1
```
```catala-test-inline
$ catala Interpret_Lcalc -s A --avoid_exceptions --optimize
[RESULT] Computation successful! Results:
[RESULT] x = ESome [ ESome $0.00; ESome $9.00; ESome $5.20 ]
```
```catala-test-inline
$ catala Interpret_Lcalc -s B --avoid_exceptions --optimize
[RESULT] Computation successful! Results:
[RESULT] max = ESome $18.00
[RESULT] min = ESome $5.00
[RESULT] y = ESome $17.20
[RESULT] z = ESome 1
```