interplane.Get Omega
Read in your language

omega-rosetta

aien-dev/omega-rosetta

Brought by drakestapleton

branch main Branches Tags History

omega-rosetta / tasks / strip-a-set-of-characters-from-a-string / strip-a-set-of-characters-from-a-string.om

43 lines · 879 bytes Raw Blame History
1note Rosetta Code task "Strip a set of characters from a string": https://rosettacode.org/wiki/Strip_a_set_of_characters_from_a_string
2note SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
3om2
4text nl "\n"
5text msg "She was a soul stripper. She took my heart!"
6text set1 "aei"
7note emit writes every byte of a to stdout; a short write is retried, an error exits 1
8fn emit a view uchar * to void
9o = ulong 0
10while lt o len a bound 4096
11k = write 1 a o sub len a o
12if le k 0
13exit 1
14end
15o = add o ulong k
16end
17end
18note emitc writes one byte
19fn emitc c uchar to void
20b = new uchar 1 0
21put b 0 c
22emit b
23end
24note stripchars writes the bytes of a that are not in set s
25fn strip a view uchar * s view uchar * to void
26for i ulong len a
27c = get a i
28k = true
29for j ulong len s
30if eq c get s j
31k = false
32end
33end
34if k
35emitc c
36end
37end
38emit nl
39end
40fn main to int
41strip msg set1
42ret 0
43end