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 / darts / .meta / example.om
| 1 | note Exercism-style exercise "darts": https://exercism.org/tracks/python/exercises/darts |
| 2 | note SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception |
| 3 | note score is the points of a dart landing at (x, y): 10 inside or on the circle of radius 1 around |
| 4 | note the centre, 5 within radius 5, 1 within radius 10, 0 outside. |
| 5 | note Check it with: sh exercise.sh exercises/darts |
| 6 | om2 |
| 7 | fn score x f64 y f64 to ulong |
| 8 | d = add mul x x mul y y |
| 9 | if le d 1.0 |
| 10 | ret 10 |
| 11 | end |
| 12 | if le d 25.0 |
| 13 | ret 5 |
| 14 | end |
| 15 | if le d 100.0 |
| 16 | ret 1 |
| 17 | end |
| 18 | ret 0 |
| 19 | end |