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-mv/blob/main/si/rosetta/tasks/strip-whitespace-from-a-string/strip-whitespace-from-a-string.om # omega-mv Omega: a language for verified programs, semantic identity and machine realization. Seed-born work and existing implementations have distinct provenance. Brought by drakestapleton Sign in to star 1 stars 0 watching About Files History Releases Proposed changes Issues For developers branch `main` Branches Tags History `omega-mv / si / rosetta / tasks / strip-whitespace-from-a-string / strip-whitespace-from-a-string.om` 53 lines ยท 1070 bytes Raw Blame History 1 note Rosetta Code task "Strip whitespace from a string/Top and tail": https://rosettacode.org/wiki/Strip_whitespace_from_a_string/Top_and_tail 2 note SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 3 om2 4 text nl "\n" 5 text lb "[" 6 text rb "]" 7 text msg " \t hello world \t\n " 8 note emit writes every byte of a to stdout; a short write is retried, an error exits 1 9 fn emit a view uchar * to void 10 o = ulong 0 11 while lt o len a bound 4096 12 k = write 1 a o sub len a o 13 if le k 0 14 exit 1 15 end 16 o = add o ulong k 17 end 18 end 19 note white: space, tab, newline, vertical tab, form feed, carriage return 20 fn white c uchar to bool 21 ret or eq c 32 and ge c 9 le c 13 22 end 23 fn lead a view uchar * to ulong 24 for i ulong len a 25 if not white get a i 26 ret i 27 end 28 end 29 ret len a 30 end 31 fn trail a view uchar * to ulong 32 for i ulong len a 33 if not white get a sub sub len a 1 i 34 ret sub len a i 35 end 36 end 37 ret 0 38 end 39 fn show a view uchar * to void 40 emit lb 41 emit a 42 emit rb 43 emit nl 44 end 45 fn main to int 46 l = lead msg 47 t = trail msg 48 show msg 49 show part msg l sub len msg l 50 show part msg 0 t 51 show part msg l sub t l 52 ret 0 53 end