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 / exercises / scrabble-score / .meta / example.om
| 1 | note Exercism-style exercise "scrabble-score": https://exercism.org/tracks/python/exercises/scrabble-score |
| 2 | note SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception |
| 3 | note score is the Scrabble score of word, ignoring case: AEIOULNRST 1, DG 2, BCMP 3, FHVWY 4, K 5, |
| 4 | note JX 8, QZ 10. |
| 5 | note Check it with: sh exercise.sh exercises/scrabble-score |
| 6 | om2 |
| 7 | note letter values A .. Z, each stored as 48 + value (":" is 10) |
| 8 | text sv "1332142418513113:11114484:" |
| 9 | fn score word view uchar * to ulong |
| 10 | t = ulong 0 |
| 11 | for i ulong len word |
| 12 | c = get word i |
| 13 | if and ge c 97 le c 122 |
| 14 | c = sub c 32 |
| 15 | end |
| 16 | if and ge c 65 le c 90 |
| 17 | t = add t ulong sub get sv ulong sub c 65 48 |
| 18 | end |
| 19 | end |
| 20 | ret t |
| 21 | end |