Skip to content

Commit

Permalink
Example codes for while, if-else, random, loop, unless, when, and maybe.
Browse files Browse the repository at this point in the history
  • Loading branch information
nthnn committed Jun 30, 2024
1 parent 2d280c6 commit 6f33e52
Show file tree
Hide file tree
Showing 7 changed files with 52 additions and 0 deletions.
8 changes: 8 additions & 0 deletions examples/example_07.utx
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;
};
7 changes: 7 additions & 0 deletions examples/example_08.utx
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";
6 changes: 6 additions & 0 deletions examples/example_09.utx
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";
5 changes: 5 additions & 0 deletions examples/example_10.utx
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";
7 changes: 7 additions & 0 deletions examples/example_11.utx
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";
12 changes: 12 additions & 0 deletions examples/example_12.utx
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"
};
7 changes: 7 additions & 0 deletions examples/example_13.utx
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";

0 comments on commit 6f33e52

Please sign in to comment.