Interplane page as plain text, for reading tools and agents. English is the reference text: translate it with your own tool. Text in backticks and in ``` blocks (commands, fingerprints, file names) and link targets in <...> are exact: copy them, never translate them. Page: /drakestapleton/omega-rosetta/blob/main/tasks/the-twelve-days-of-christmas/the-twelve-days-of-christmas.om # omega-rosetta aien-dev/omega-rosetta Brought by drakestapleton Sign in to star 0 stars 0 watching About Files History Releases Proposed changes Issues For developers branch `main` Branches Tags History `omega-rosetta / tasks / the-twelve-days-of-christmas / the-twelve-days-of-christmas.om` 60 lines ยท 1520 bytes Raw Blame History 1 note Rosetta Code task "The Twelve Days of Christmas": https://rosettacode.org/wiki/The_Twelve_Days_of_Christmas 2 note SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 3 om2 4 text nl "\n" 5 text on "On the " 6 text day " day of Christmas,\nMy true love sent to me:\n" 7 text last "And a partridge in a pear tree." 8 text days "first\nsecond\nthird\nfourth\nfifth\nsixth\nseventh\neighth\nninth\ntenth\neleventh\ntwelfth\n" 9 text 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" 10 note emit writes every byte of a to stdout; a short write is retried, an error exits 1 11 fn emit a view uchar * to void 12 o = ulong 0 13 while lt o len a bound 4096 14 k = write 1 a o sub len a o 15 if le k 0 16 exit 1 17 end 18 o = add o ulong k 19 end 20 end 21 note word writes element k of a newline-terminated list, without the newline 22 fn word t view uchar * k ulong to void 23 s = ulong 0 24 m = ulong 0 25 for i ulong len t 26 if eq get t i 10 27 if eq m k 28 emit part t s sub i s 29 ret 30 end 31 m = add m 1 32 s = add i 1 33 end 34 end 35 trap 9 36 end 37 note verse d lists gifts d down to 0; from the second day on the partridge line starts "And a" 38 fn verse d ulong to void 39 emit on 40 word days d 41 emit day 42 for k ulong add d 1 43 g = sub d k 44 if and eq g 0 gt d 0 45 emit last 46 else 47 word gifts g 48 end 49 emit nl 50 end 51 end 52 fn main to int 53 for d ulong 12 54 if gt d 0 55 emit nl 56 end 57 verse d 58 end 59 ret 0 60 end