interplane.Get Omega
Read in your language

omega-rosetta

aien-dev/omega-rosetta

Brought by drakestapleton

branch main Branches Tags History

omega-rosetta / drafts / rosettacode / strip-a-set-of-characters-from-a-string.wiki

50 lines · 997 bytes Raw Blame History
1=={{header|Omegese}}==
2{{works with|omc|sha256 2c824805, aien-dev/omega-mv e5b32567, Linux AArch64}}
3Omega has no imports, so the small output helpers (<code>emit</code> and friends) are part of the program.
4<syntaxhighlight lang="text">
5om2
6text nl "\n"
7text msg "She was a soul stripper. She took my heart!"
8text set1 "aei"
9note emit writes every byte of a to stdout; a short write is retried, an error exits 1
10fn emit a view uchar * to void
11o = ulong 0
12while lt o len a bound 4096
13k = write 1 a o sub len a o
14if le k 0
15exit 1
16end
17o = add o ulong k
18end
19end
20note emitc writes one byte
21fn emitc c uchar to void
22b = new uchar 1 0
23put b 0 c
24emit b
25end
26note stripchars writes the bytes of a that are not in set s
27fn strip a view uchar * s view uchar * to void
28for i ulong len a
29c = get a i
30k = true
31for j ulong len s
32if eq c get s j
33k = false
34end
35end
36if k
37emitc c
38end
39end
40emit nl
41end
42fn main to int
43strip msg set1
44ret 0
45end
46</syntaxhighlight>
47{{out}}
48<pre>
49Sh ws soul strppr. Sh took my hrt!
50</pre>