Using Statements
If-Else, If-Then-Else, While and Compound statements are also supported in the Rason modeling language. See below for syntax and useage examples of each.
If-Else and If-Then-Else Statement Examples
The else part in both IF statements above is optional. Notice that both If statements are the only place in Rason where two formulas may be assigned to the same identifier.
If - Else Example
"if (logic_exp)" : {
f: {...},
...
},
"else":{
f: {...},
...
}
If - Then - Else Example
F: { if: "logic_exp", then: "formula1", else: "formula2" }
While Example
This example illustrates how to use a "while" statement in the Rason modeling language.
"while ( logic_exp)": {
…
}
Compound Example
The "body" in all statements is an implicit compound stgatement – a sequence of definitions and nested statements. The only case when we may need an explicit compound statement, is when initializing an identifier before using it in a next loop statement as shown below.
"compound" : {
i: {value: 1},
…
}
Back to Using a Fully Scalable Model Loop
|