omega-mv
Omega: a language for verified programs, semantic identity and machine realization. Seed-born work and existing implementations have distinct provenance.
Brought by drakestapleton
omega-mv / si / rosetta / tasks / repeat-a-string / repeat-a-string.om
| 1 | note Rosetta Code task "Repeat a string": https://rosettacode.org/wiki/Repeat_a_string |
| 2 | note SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception |
| 3 | om2 |
| 4 | text nl "\n" |
| 5 | text ha "ha" |
| 6 | text star "*" |
| 7 | note emit writes every byte of a to stdout; a short write is retried, an error exits 1 |
| 8 | fn emit a view uchar * to void |
| 9 | o = ulong 0 |
| 10 | while lt o len a bound 4096 |
| 11 | k = write 1 a o sub len a o |
| 12 | if le k 0 |
| 13 | exit 1 |
| 14 | end |
| 15 | o = add o ulong k |
| 16 | end |
| 17 | end |
| 18 | note repeat writes a, k times, into one buffer (up to 256 bytes, more traps 3) and prints it |
| 19 | fn repeat a view uchar * k ulong to void |
| 20 | b = new uchar 256 0 |
| 21 | p = ulong 0 |
| 22 | for j ulong k |
| 23 | for i ulong len a |
| 24 | put b p get a i |
| 25 | p = add p 1 |
| 26 | end |
| 27 | end |
| 28 | emit part b 0 p |
| 29 | emit nl |
| 30 | end |
| 31 | fn main to int |
| 32 | repeat ha 5 |
| 33 | repeat star 5 |
| 34 | ret 0 |
| 35 | end |