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 / triangle / .meta / example.om
| 1 | note Exercism-style exercise "triangle": https://exercism.org/tracks/python/exercises/triangle |
| 2 | note SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception |
| 3 | note The sides a b c form a triangle when each is greater than 0 and the sum of any two is at least |
| 4 | note the third. equilateral: a triangle with all three sides equal; isosceles: a triangle with at |
| 5 | note least two sides equal; scalene: a triangle with all sides different. |
| 6 | note Check it with: sh exercise.sh exercises/triangle |
| 7 | om2 |
| 8 | fn istri a f64 b f64 c f64 to bool |
| 9 | if or or le a 0.0 le b 0.0 le c 0.0 |
| 10 | ret false |
| 11 | end |
| 12 | ret and and ge add a b c ge add b c a ge add a c b |
| 13 | end |
| 14 | fn equilateral a f64 b f64 c f64 to bool |
| 15 | ret and istri a b c and eq a b eq b c |
| 16 | end |
| 17 | fn isosceles a f64 b f64 c f64 to bool |
| 18 | ret and istri a b c or or eq a b eq b c eq a c |
| 19 | end |
| 20 | fn scalene a f64 b f64 c f64 to bool |
| 21 | ret and istri a b c and and ne a b ne b c ne a c |
| 22 | end |