If Condition

Source: reference-book. Raw markdown: /raw/docs/reference-book/9-common-patterns/if-condition.md

Conditions are a core feature of any programming language. Using conditions we will control the flow of program execution.

A typical classical if condition in a CPL is more or less similar to,

if (x == 10 ) {
    printf("X is 10");
}

Considering what we saw so far in the previous chapters, it's quite clear that the above classical control flow now is naturally available using simorg's dataflow model.

In fact the natural behavior of a <<<Conditional Shell>>> is providing the same exact functionality of a classical <<<if statement>>>.

The above example can be re-written as,

x = 10 {
    "X is 10"?
}

To support the <<<And Condition>>> we simply use an <<<AND Gate>>>,

(x = 10, y = 20) {
    "X is 10 and Y is 20"?
}