catala/tests/test_struct/good/nested3.catala_en
2022-11-21 17:11:53 +01:00

51 lines
963 B
Plaintext

## Article
```catala
declaration structure S:
data x content integer
data y content boolean
declaration structure T:
data a content S
data b content S
declaration scope A:
context output t content T
declaration scope B:
context output t content T
a scope A
context output out content integer
scope A:
definition t equals T {
-- a : S {
-- x : 0
-- y : false
}
-- b : S {
-- x : 1
-- y : true
}
}
scope B:
definition t equals a.t
definition out equals if t.a.y then t.a.x else (if t.b.y then t.b.x else 42)
```
```catala-test-inline
$ catala Interpret -s A
[RESULT] Computation successful! Results:
[RESULT] t =
T { "a"= S { "x"= 0; "y"= false }; "b"= S { "x"= 1; "y"= true } }
```
```catala-test-inline
$ catala Interpret -s B
[RESULT] Computation successful! Results:
[RESULT] out = 1
[RESULT] t =
T { "a"= S { "x"= 0; "y"= false }; "b"= S { "x"= 1; "y"= true } }
```