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 / 99-bottles-of-beer.wiki

94 lines · 1728 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 nl "\n"
7text nomore "No more"
8text b1 " bottle"
9text bn " bottles"
10text wall " of beer on the wall\n"
11text beer " of beer\n"
12text take "Take one down, pass it around\n"
13note emit writes every byte of a to stdout; a short write is retried, an error exits 1
14fn emit a view uchar * to void
15o = ulong 0
16while lt o len a bound 4096
17k = write 1 a o sub len a o
18if le k 0
19exit 1
20end
21o = add o ulong k
22end
23end
24note emitu writes n in decimal; 20 digits hold every ulong
25fn emitu n ulong to void
26d = new uchar 20 0
27i = ulong 20
28v = n
29while true bound 20
30i = sub i 1
31put d i uchar add rem v 10 48
32v = div v 10
33if eq v 0
34break
35end
36end
37emit part d i sub 20 i
38end
39fn bottles n ulong to void
40if eq n 0
41emit nomore
42else
43emitu n
44end
45if eq n 1
46emit b1
47else
48emit bn
49end
50end
51fn main to int
52for i ulong 99
53n = sub 99 i
54bottles n
55emit wall
56bottles n
57emit beer
58emit take
59bottles sub n 1
60emit wall
61if lt i 98
62emit nl
63end
64end
65ret 0
66end
67</syntaxhighlight>
68{{out}}
69<pre>
7099 bottles of beer on the wall
7199 bottles of beer
72Take one down, pass it around
7398 bottles of beer on the wall
74
7598 bottles of beer on the wall
7698 bottles of beer
77Take one down, pass it around
7897 bottles of beer on the wall
79
8097 bottles of beer on the wall
8197 bottles of beer
82Take one down, pass it around
8396 bottles of beer on the wall
84
85...
862 bottles of beer
87Take one down, pass it around
881 bottle of beer on the wall
89
901 bottle of beer on the wall
911 bottle of beer
92Take one down, pass it around
93No more bottles of beer on the wall
94</pre>