omega-rosetta
aien-dev/omega-rosetta
Brought by drakestapleton
omega-rosetta / drafts / rosettacode / loops-for.wiki
| 1 | =={{header|Omegese}}== |
| 2 | {{works with|omc|sha256 2c824805, aien-dev/omega-mv e5b32567, Linux AArch64}} |
| 3 | Omega has no imports, so the small output helpers (<code>emit</code> and friends) are part of the program. |
| 4 | <syntaxhighlight lang="text"> |
| 5 | om2 |
| 6 | text nl "\n" |
| 7 | text star "*" |
| 8 | note emit writes every byte of a to stdout; a short write is retried, an error exits 1 |
| 9 | fn emit a view uchar * to void |
| 10 | o = ulong 0 |
| 11 | while lt o len a bound 4096 |
| 12 | k = write 1 a o sub len a o |
| 13 | if le k 0 |
| 14 | exit 1 |
| 15 | end |
| 16 | o = add o ulong k |
| 17 | end |
| 18 | end |
| 19 | note row i has i + 1 stars, five rows |
| 20 | fn main to int |
| 21 | for i ulong 5 |
| 22 | for j ulong add i 1 |
| 23 | emit star |
| 24 | end |
| 25 | emit nl |
| 26 | end |
| 27 | ret 0 |
| 28 | end |
| 29 | </syntaxhighlight> |
| 30 | {{out}} |
| 31 | <pre> |
| 32 | * |
| 33 | ** |
| 34 | *** |
| 35 | **** |
| 36 | ***** |
| 37 | </pre> |