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 / two-fer / .meta / example.om
| 1 | note Exercism-style exercise "two-fer": https://exercism.org/tracks/python/exercises/two-fer |
| 2 | note SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception |
| 3 | note twofer writes "One for X, one for me." into o, X being name, or "you" when name is empty, |
| 4 | note and returns the number of bytes written. |
| 5 | note Check it with: sh exercise.sh exercises/two-fer |
| 6 | om2 |
| 7 | text ofa "One for " |
| 8 | text ofb ", one for me." |
| 9 | text ofy "you" |
| 10 | fn app o edit uchar * p ulong s view uchar * to ulong |
| 11 | q = p |
| 12 | for i ulong len s |
| 13 | put o q get s i |
| 14 | q = add q 1 |
| 15 | end |
| 16 | ret q |
| 17 | end |
| 18 | fn twofer name view uchar * o edit uchar * to ulong |
| 19 | p = app o 0 ofa |
| 20 | if eq len name 0 |
| 21 | p = app o p ofy |
| 22 | else |
| 23 | p = app o p name |
| 24 | end |
| 25 | p = app o p ofb |
| 26 | ret p |
| 27 | end |