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/comma-quibbling/comma-quibbling.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 / comma-quibbling / comma-quibbling.om` 65 lines ยท 1162 bytes Raw Blame History 1 note Rosetta Code task "Comma quibbling": https://rosettacode.org/wiki/Comma_quibbling 2 note SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 3 om2 4 text nl "\n" 5 text lb "{" 6 text rb "}" 7 text sep ", " 8 text tand " and " 9 text w1 "ABC" 10 text w2 "ABC DEF" 11 text w3 "ABC DEF G H" 12 note emit writes every byte of a to stdout; a short write is retried, an error exits 1 13 fn emit a view uchar * to void 14 o = ulong 0 15 while lt o len a bound 4096 16 k = write 1 a o sub len a o 17 if le k 0 18 exit 1 19 end 20 o = add o ulong k 21 end 22 end 23 note quib takes the words of a (single spaces between them): all but the last two are followed by a 24 note comma, the last two are joined by "and", inside braces 25 fn quib a view uchar * to void 26 st = new ulong 16 0 27 ln = new ulong 16 0 28 k = ulong 0 29 s = ulong 0 30 for i ulong add len a 1 31 e = eq i len a 32 if not e 33 e = eq get a i 32 34 end 35 if and e gt i s 36 put st k s 37 put ln k sub i s 38 k = add k 1 39 end 40 if e 41 s = add i 1 42 end 43 end 44 emit lb 45 for w ulong k 46 if gt w 0 47 if eq w sub k 1 48 emit tand 49 else 50 emit sep 51 end 52 end 53 emit part a get st w get ln w 54 end 55 emit rb 56 emit nl 57 end 58 fn main to int 59 note the empty list, as a slice of length 0 60 quib part w1 0 0 61 quib w1 62 quib w2 63 quib w3 64 ret 0 65 end