interplane.Get Omega
Read in your language

omega-rosetta

aien-dev/omega-rosetta

Brought by drakestapleton

branch main Branches Tags History

omega-rosetta / drafts / rosettacode / leap-year.wiki

71 lines · 1251 bytes Raw Blame History
1=={{header|Omegese}}==
2{{works with|omc|sha256 2c824805, aien-dev/omega-mv e5b32567, Linux AArch64}}
3Omega has no imports, so the small output helpers (<code>emit</code> and friends) are part of the program.
4<syntaxhighlight lang="text">
5om2
6text yes " is a leap year\n"
7text no " is not a leap year\n"
8note emit writes every byte of a to stdout; a short write is retried, an error exits 1
9fn emit a view uchar * to void
10o = ulong 0
11while lt o len a bound 4096
12k = write 1 a o sub len a o
13if le k 0
14exit 1
15end
16o = add o ulong k
17end
18end
19note emitu writes n in decimal; 20 digits hold every ulong
20fn emitu n ulong to void
21d = new uchar 20 0
22i = ulong 20
23v = n
24while true bound 20
25i = sub i 1
26put d i uchar add rem v 10 48
27v = div v 10
28if eq v 0
29break
30end
31end
32emit part d i sub 20 i
33end
34fn leap y ulong to bool
35if eq rem y 400 0
36ret true
37end
38if eq rem y 100 0
39ret false
40end
41ret eq rem y 4 0
42end
43fn show y ulong to void
44emitu y
45if leap y
46emit yes
47else
48emit no
49end
50end
51fn main to int
52show 1900
53show 1996
54show 2000
55show 2023
56show 2024
57show 2100
58show 2400
59ret 0
60end
61</syntaxhighlight>
62{{out}}
63<pre>
641900 is not a leap year
651996 is a leap year
662000 is a leap year
672023 is not a leap year
682024 is a leap year
692100 is not a leap year
702400 is a leap year
71</pre>