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 / remove-vowels-from-a-string / remove-vowels-from-a-string.om
| 1 | note Rosetta Code task "Remove vowels from a string": https://rosettacode.org/wiki/Remove_vowels_from_a_string |
| 2 | note SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception |
| 3 | om2 |
| 4 | text nl "\n" |
| 5 | text msg "Rosetta Code is a programming chrestomathy site, AEIOU and aeiou alike." |
| 6 | text vow "aeiouAEIOU" |
| 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 emitc writes one byte |
| 19 | fn emitc c uchar to void |
| 20 | b = new uchar 1 0 |
| 21 | put b 0 c |
| 22 | emit b |
| 23 | end |
| 24 | fn isvowel c uchar to bool |
| 25 | for i ulong len vow |
| 26 | if eq c get vow i |
| 27 | ret true |
| 28 | end |
| 29 | end |
| 30 | ret false |
| 31 | end |
| 32 | fn main to int |
| 33 | emit msg |
| 34 | emit nl |
| 35 | for i ulong len msg |
| 36 | c = get msg i |
| 37 | if not isvowel c |
| 38 | emitc c |
| 39 | end |
| 40 | end |
| 41 | emit nl |
| 42 | ret 0 |
| 43 | end |