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-mv/blob/main/si/rosetta/tasks/jewels-and-stones/jewels-and-stones.om # 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 Sign in to star 1 stars 0 watching About Files History Releases Proposed changes Issues For developers branch `main` Branches Tags History `omega-mv / si / rosetta / tasks / jewels-and-stones / jewels-and-stones.om` 61 lines ยท 1107 bytes Raw Blame History 1 note Rosetta Code task "Jewels and stones": https://rosettacode.org/wiki/Jewels_and_stones 2 note SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 3 om2 4 text nl "\n" 5 text sp " " 6 text s1 "aAAbbbb" 7 text j1 "aA" 8 text s2 "ZZ" 9 text j2 "z" 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 emitu writes n in decimal; 20 digits hold every ulong 22 fn emitu n ulong to void 23 d = new uchar 20 0 24 i = ulong 20 25 v = n 26 while true bound 20 27 i = sub i 1 28 put d i uchar add rem v 10 48 29 v = div v 10 30 if eq v 0 31 break 32 end 33 end 34 emit part d i sub 20 i 35 end 36 note count the stones (bytes of s) that are jewels (occur in j); case matters 37 fn jewels s view uchar * j view uchar * to ulong 38 n = ulong 0 39 for i ulong len s 40 for k ulong len j 41 if eq get s i get j k 42 n = add n 1 43 break 44 end 45 end 46 end 47 ret n 48 end 49 fn show s view uchar * j view uchar * to void 50 emit s 51 emit sp 52 emit j 53 emit sp 54 emitu jewels s j 55 emit nl 56 end 57 fn main to int 58 show s1 j1 59 show s2 j2 60 ret 0 61 end