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 / tasks / the-twelve-days-of-christmas / the-twelve-days-of-christmas.om

60 lines · 1520 bytes Raw Blame History
1note Rosetta Code task "The Twelve Days of Christmas": https://rosettacode.org/wiki/The_Twelve_Days_of_Christmas
2note SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
3om2
4text nl "\n"
5text on "On the "
6text day " day of Christmas,\nMy true love sent to me:\n"
7text last "And a partridge in a pear tree."
8text days "first\nsecond\nthird\nfourth\nfifth\nsixth\nseventh\neighth\nninth\ntenth\neleventh\ntwelfth\n"
9text gifts "A partridge in a pear tree.\nTwo turtle doves,\nThree french hens,\nFour calling birds,\nFive golden rings,\nSix geese a-laying,\nSeven swans a-swimming,\nEight maids a-milking,\nNine ladies dancing,\nTen lords a-leaping,\nEleven pipers piping,\nTwelve drummers drumming,\n"
10note emit writes every byte of a to stdout; a short write is retried, an error exits 1
11fn emit a view uchar * to void
12o = ulong 0
13while lt o len a bound 4096
14k = write 1 a o sub len a o
15if le k 0
16exit 1
17end
18o = add o ulong k
19end
20end
21note word writes element k of a newline-terminated list, without the newline
22fn word t view uchar * k ulong to void
23s = ulong 0
24m = ulong 0
25for i ulong len t
26if eq get t i 10
27if eq m k
28emit part t s sub i s
29ret
30end
31m = add m 1
32s = add i 1
33end
34end
35trap 9
36end
37note verse d lists gifts d down to 0; from the second day on the partridge line starts "And a"
38fn verse d ulong to void
39emit on
40word days d
41emit day
42for k ulong add d 1
43g = sub d k
44if and eq g 0 gt d 0
45emit last
46else
47word gifts g
48end
49emit nl
50end
51end
52fn main to int
53for d ulong 12
54if gt d 0
55emit nl
56end
57verse d
58end
59ret 0
60end