-
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Example codes for while, if-else, random, loop, unless, when, and maybe.
- Loading branch information
Showing
7 changed files
with
52 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
#!/usr/local/bin/uartix | ||
# Increment i variable using while | ||
|
||
i = 0; | ||
while(i < 10) { | ||
render i + "\r\n"; | ||
i = i + 1; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
#!/usr/local/bin/uartix | ||
# Checking x if positive or negative number with if-else | ||
|
||
x = 10; | ||
if(x > 0) | ||
render "x is a positive number\r\n" | ||
else render "x is a negative number\r\n"; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
#!/usr/local/bin/uartix | ||
# Execute a render expression randomly. | ||
|
||
random | ||
render "Randomly rendered string.\r\n" | ||
else render "Executing the else-clause.\r\n"; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
#!/usr/local/bin/uartix | ||
# Loop expression example equivalent to for-loop in other languages. | ||
|
||
loop(i = 0; i < 10; i = i + 1) | ||
render i+ "\r\n"; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
#!/usr/local/bin/uartix | ||
# Execute unless expression if x is not 0. | ||
|
||
x = 3.14; | ||
unless(x == 0) | ||
render "x is not zero.\r\n" | ||
else render "x is zero\r\n"; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
#!/usr/local/bin/uartix | ||
# When expression to render equivalent day for a number. | ||
|
||
day = 1; | ||
when(day) { | ||
if(0) render "Monday", | ||
if(1) render "Tuesday", | ||
if(2) render "Wednesday", | ||
if(3) render "Thursday", | ||
if(4) render "Friday", | ||
else render "Weekday" | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
#!/usr/local/bin/uartix | ||
# Print a string if the maybe has a true value. | ||
|
||
should_print = maybe; | ||
if(should_print) | ||
render "Maybe had a true value.\r\n" | ||
else render "Maybe had a false value.\r\n"; |