| summaryrefslogtreecommitdiff |
diff options
| author | Nathanael Sensfelder <SpamShield0@MultiAgentSystems.org> | 2020-12-22 04:08:34 +0100 |
|---|---|---|
| committer | Nathanael Sensfelder <SpamShield0@MultiAgentSystems.org> | 2020-12-22 04:08:34 +0100 |
| commit | d0d6117176d68b2345d36e81ccdaa447e9caa724 (patch) | |
| tree | 6cb8f3e4735a695be8c0922434df4c60f7cf82c7 /content/fate_v1/computations/conditionals | |
Moving to Hugo.
Diffstat (limited to 'content/fate_v1/computations/conditionals')
| -rw-r--r-- | content/fate_v1/computations/conditionals/_index.md | 54 |
1 files changed, 54 insertions, 0 deletions
diff --git a/content/fate_v1/computations/conditionals/_index.md b/content/fate_v1/computations/conditionals/_index.md new file mode 100644 index 0000000..2953489 --- /dev/null +++ b/content/fate_v1/computations/conditionals/_index.md @@ -0,0 +1,54 @@ +--- +title: Conditionals +--- +This page presents the computation operators that allow a choice depending on +some condition. All possible returned values must be of the same type. + +### IF-ELSE +{{< fatecode >}}(if_else [BOOL] [C0 = COMPUTATION] [C1 = COMPUTATION]){{< /fatecode >}} + +Returns `C0` is `[BOOL]` yields true, `C1` otherwise. + +### COND +{{< fatecode >}}(cond ([B0 = BOOL] [C0 = COMPUTATION]) ... ([BN = BOOL] [CN = COMPUTATION])){{< /fatecode >}} + +Returns `<Ci>`, such that `<Bi>` is the first to hold true. If there is not such +`Bi`, returns `[CN]`. + +### SWITCH +{{< fatecode >}}(switch [T = COMPUTATION] ([V0 = COMPUTATION] [C0 = COMPUTATION]) ... ([VN = BOOL] [CN = COMPUTATION]) [D = COMPUTATION]){{< /fatecode >}}a + +Returns the first `Ci` such that `Vi` is equal to `T`. If there is not such +`Vi`, returns `[D]`. + +## Examples +{{< fatecode >}}(cond + ((false) (false)) + ((false) (false)) + ((true) + (cond + ((false) (false)) + ((true) (not (is_member 3 test_list))) + ((true) (false)) + ) + ) +) +{{< /fatecode >}} + +{{< fatecode >}}(switch 3 + (0 (false)) + (1 (false)) + (3 (true)) + (2 (false)) + (false) +) +{{< /fatecode >}} + +{{< fatecode >}}(if_else (true) + (if_else (false) + (assert (false) FAILED: instruction ifelse E) + (set test_var (true)) + ) + (assert (false) FAILED: instruction ifelse F) +) +{{< /fatecode >}} |


