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 / tokenize-a-string.wiki

47 lines · 1003 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 dot "."
8text msg "Hello,How,Are,You,Today"
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 splits at every comma, keeps the pieces as (start, length) pairs, then joins them with periods
21fn main to int
22st = new ulong 64 0
23ln = new ulong 64 0
24k = ulong 0
25s = ulong 0
26for i ulong add len msg 1
27if or eq i len msg eq get msg rem i len msg 44
28put st k s
29put ln k sub i s
30k = add k 1
31s = add i 1
32end
33end
34for j ulong k
35if gt j 0
36emit dot
37end
38emit part msg get st j get ln j
39end
40emit nl
41ret 0
42end
43</syntaxhighlight>
44{{out}}
45<pre>
46Hello.How.Are.You.Today
47</pre>