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/loops-n-plus-one-half/loops-n-plus-one-half.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 / loops-n-plus-one-half / loops-n-plus-one-half.om` 45 lines ยท 888 bytes Raw Blame History 1 note Rosetta Code task "Loops/N plus one half": https://rosettacode.org/wiki/Loops/N_plus_one_half 2 note SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 3 om2 4 text nl "\n" 5 text sep ", " 6 note emit writes every byte of a to stdout; a short write is retried, an error exits 1 7 fn emit a view uchar * to void 8 o = ulong 0 9 while lt o len a bound 4096 10 k = write 1 a o sub len a o 11 if le k 0 12 exit 1 13 end 14 o = add o ulong k 15 end 16 end 17 note emitu writes n in decimal; 20 digits hold every ulong 18 fn emitu n ulong to void 19 d = new uchar 20 0 20 i = ulong 20 21 v = n 22 while true bound 20 23 i = sub i 1 24 put d i uchar add rem v 10 48 25 v = div v 10 26 if eq v 0 27 break 28 end 29 end 30 emit part d i sub 20 i 31 end 32 note the loop writes the number, leaves at 10, else the separator: the last pass is half a pass 33 fn main to int 34 i = ulong 1 35 while true bound 100 36 emitu i 37 if eq i 10 38 break 39 end 40 emit sep 41 i = add i 1 42 end 43 emit nl 44 ret 0 45 end