interplane.Get Omega
Read in your language

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

branch main Branches Tags History

omega-mv / si / rosetta / exercises / space-age / .meta / example.om

61 lines · 1323 bytes Raw Blame History
1note Exercism-style exercise "space-age": https://exercism.org/tracks/python/exercises/space-age
2note SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
3note age is how old someone of the given seconds is in years of planet: one Earth year is 31557600
4note seconds; orbital periods in Earth years are Mercury 0.2408467, Venus 0.61519726, Earth 1.0,
5note Mars 1.8808158, Jupiter 11.862615, Saturn 29.447498, Uranus 84.016846, Neptune 164.79132.
6note age is -1.0 when planet is not one of these names.
7note Check it with: sh exercise.sh exercises/space-age
8om2
9text pl0 "Mercury"
10text pl1 "Venus"
11text pl2 "Earth"
12text pl3 "Mars"
13text pl4 "Jupiter"
14text pl5 "Saturn"
15text pl6 "Uranus"
16text pl7 "Neptune"
17fn same a view uchar * b view uchar * to bool
18if ne len a len b
19ret false
20end
21for i ulong len a
22if ne get a i get b i
23ret false
24end
25end
26ret true
27end
28fn period planet view uchar * to f64
29if same planet pl0
30ret 0.2408467
31end
32if same planet pl1
33ret 0.61519726
34end
35if same planet pl2
36ret 1.0
37end
38if same planet pl3
39ret 1.8808158
40end
41if same planet pl4
42ret 11.862615
43end
44if same planet pl5
45ret 29.447498
46end
47if same planet pl6
48ret 84.016846
49end
50if same planet pl7
51ret 164.79132
52end
53ret -1.0
54end
55fn age planet view uchar * seconds f64 to f64
56p = period planet
57if lt p 0.0
58ret -1.0
59end
60ret div div seconds 31557600.0 p
61end