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/drafts/rosettacode/string-matching.wiki # 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 / drafts / rosettacode / string-matching.wiki` 83 lines ยท 1472 bytes Raw Blame History 1 =={{header|Omegese}}== 2 {{works with|omc|sha256 `2c824805`, aien-dev/omega-mv `e5b32567`, Linux AArch64}} 3 Omega has no imports, so the small output helpers (emit and friends) are part of the program. 4 5 om2 6 text nl "\n" 7 text sp " " 8 text hay "tacoloco" 9 text nd "co" 10 text tst "starts with: " 11 text tct "found at:" 12 text ten "ends with: " 13 text tyes "yes" 14 text tno "no" 15 note emit writes every byte of a to stdout; a short write is retried, an error exits 1 16 fn emit a view uchar * to void 17 o = ulong 0 18 while lt o len a bound 4096 19 k = write 1 a o sub len a o 20 if le k 0 21 exit 1 22 end 23 o = add o ulong k 24 end 25 end 26 note emitu writes n in decimal; 20 digits hold every ulong 27 fn emitu n ulong to void 28 d = new uchar 20 0 29 i = ulong 20 30 v = n 31 while true bound 20 32 i = sub i 1 33 put d i uchar add rem v 10 48 34 v = div v 10 35 if eq v 0 36 break 37 end 38 end 39 emit part d i sub 20 i 40 end 41 fn emitb b bool to void 42 if b 43 emit tyes 44 else 45 emit tno 46 end 47 end 48 note at tells whether t occurs in s at offset i (false when it would run past the end) 49 fn at2 s view uchar * t view uchar * i ulong to bool 50 if gt add i len t len s 51 ret false 52 end 53 for j ulong len t 54 if ne get s add i j get t j 55 ret false 56 end 57 end 58 ret true 59 end 60 fn main to int 61 emit tst 62 emitb at2 hay nd 0 63 emit nl 64 emit tct 65 for i ulong len hay 66 if at2 hay nd i 67 emit sp 68 emitu i 69 end 70 end 71 emit nl 72 emit ten 73 emitb at2 hay nd sub len hay len nd 74 emit nl 75 ret 0 76 end 77 78 {{out}} 79

80 starts with: no

81 found at: 2 6

82 ends with: yes

83