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/tasks/tokenize-a-string/tokenize-a-string.om # 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 / tasks / tokenize-a-string / tokenize-a-string.om` 40 lines ยท 853 bytes Raw Blame History 1 note Rosetta Code task "Tokenize a string": https://rosettacode.org/wiki/Tokenize_a_string 2 note SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 3 om2 4 text nl "\n" 5 text dot "." 6 text msg "Hello,How,Are,You,Today" 7 note emit writes every byte of a to stdout; a short write is retried, an error exits 1 8 fn emit a view uchar * to void 9 o = ulong 0 10 while lt o len a bound 4096 11 k = write 1 a o sub len a o 12 if le k 0 13 exit 1 14 end 15 o = add o ulong k 16 end 17 end 18 note splits at every comma, keeps the pieces as (start, length) pairs, then joins them with periods 19 fn main to int 20 st = new ulong 64 0 21 ln = new ulong 64 0 22 k = ulong 0 23 s = ulong 0 24 for i ulong add len msg 1 25 if or eq i len msg eq get msg rem i len msg 44 26 put st k s 27 put ln k sub i s 28 k = add k 1 29 s = add i 1 30 end 31 end 32 for j ulong k 33 if gt j 0 34 emit dot 35 end 36 emit part msg get st j get ln j 37 end 38 emit nl 39 ret 0 40 end