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 / pangram-checker / pangram-checker.om
| 1 | note Rosetta Code task "Pangram checker": https://rosettacode.org/wiki/Pangram_checker |
| 2 | note SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception |
| 3 | om2 |
| 4 | text nl "\n" |
| 5 | text tq "\"" |
| 6 | text tis "\" is a pangram\n" |
| 7 | text tnot "\" is not a pangram\n" |
| 8 | text p1 "The quick brown fox jumps over the lazy dog" |
| 9 | text p2 "The quick brown fox jumped over the lazy dog" |
| 10 | text p3 "Pack my box with five dozen liquor jugs." |
| 11 | note emit writes every byte of a to stdout; a short write is retried, an error exits 1 |
| 12 | fn emit a view uchar * to void |
| 13 | o = ulong 0 |
| 14 | while lt o len a bound 4096 |
| 15 | k = write 1 a o sub len a o |
| 16 | if le k 0 |
| 17 | exit 1 |
| 18 | end |
| 19 | o = add o ulong k |
| 20 | end |
| 21 | end |
| 22 | fn pangram a view uchar * to bool |
| 23 | seen = new uchar 26 0 |
| 24 | for i ulong len a |
| 25 | c = get a i |
| 26 | if and ge c 65 le c 90 |
| 27 | c = add c 32 |
| 28 | end |
| 29 | if and ge c 97 le c 122 |
| 30 | put seen sub c 97 1 |
| 31 | end |
| 32 | end |
| 33 | for j ulong 26 |
| 34 | if eq get seen j 0 |
| 35 | ret false |
| 36 | end |
| 37 | end |
| 38 | ret true |
| 39 | end |
| 40 | fn show a view uchar * to void |
| 41 | emit tq |
| 42 | emit a |
| 43 | if pangram a |
| 44 | emit tis |
| 45 | else |
| 46 | emit tnot |
| 47 | end |
| 48 | end |
| 49 | fn main to int |
| 50 | show p1 |
| 51 | show p2 |
| 52 | show p3 |
| 53 | ret 0 |
| 54 | end |