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/substring.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 / substring.wiki`
59 lines ยท 1198 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 str "abcdefgh"
8 text cd "cd"
9 note emit writes every byte of a to stdout; a short write is retried, an error exits 1
10 fn emit a view uchar * to void
11 o = ulong 0
12 while lt o len a bound 4096
13 k = write 1 a o sub len a o
14 if le k 0
15 exit 1
16 end
17 o = add o ulong k
18 end
19 end
20 note find returns the first index where t occurs in s; a missing t traps 9
21 fn find s view uchar * t view uchar * to ulong
22 for i ulong add sub len s len t 1
23 m = true
24 for j ulong len t
25 if ne get s add i j get t j
26 m = false
27 end
28 end
29 if m
30 ret i
31 end
32 end
33 trap 9
34 end
35 fn line a view uchar * to void
36 emit a
37 emit nl
38 end
39 fn main to int
40 n = ulong 2
41 m = ulong 3
42 note n characters in, m long; from n to the end; all but the last; from d, m long; from cd, m long
43 line part str n m
44 line part str n sub len str n
45 line part str 0 sub len str 1
46 c = new uchar 1 100
47 line part str find str c m
48 line part str find str cd m
49 ret 0
50 end
51
52 {{out}}
53
54 cde
55 cdefgh
56 abcdefg
57 def
58 cde
59