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/drafts/rosettacode/empty-string.wiki
# 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 / drafts / rosettacode / empty-string.wiki`
54 lines ยท 1177 bytes Raw Blame History
1 =={{header|Omegese}}==
2 {{works with|omc|sha256 `2c824805`, aien-dev/omega-mv `e5b32567`, Linux AArch64}}
3 Omega has no imports, so the small output helpers (emit and friends) are part of the program.
4
5 om2
6 text nl "\n"
7 text tempty "s is empty\n"
8 text tfull "s is not empty: "
9 text word "abc"
10 note emit writes every byte of a to stdout; a short write is retried, an error exits 1
11 fn emit a view uchar * to void
12 o = ulong 0
13 while lt o len a bound 4096
14 k = write 1 a o sub len a o
15 if le k 0
16 exit 1
17 end
18 o = add o ulong k
19 end
20 end
21 note copyto copies s into d at offset off and returns the offset after it (past the end traps 3)
22 fn copyto d edit uchar * off ulong s view uchar * to ulong
23 for i ulong len s
24 put d add off i get s i
25 end
26 ret add off len s
27 end
28 note a string here is a buffer b and its length n; the empty string is length 0
29 fn check b view uchar * to void
30 if eq len b 0
31 emit tempty
32 else
33 emit tfull
34 emit b
35 emit nl
36 end
37 end
38 fn main to int
39 b = new uchar 16 0
40 n = ulong 0
41 check part b 0 n
42 n = copyto b 0 word
43 check part b 0 n
44 n = 0
45 check part b 0 n
46 ret 0
47 end
48
49 {{out}}
50
51 s is empty
52 s is not empty: abc
53 s is empty
54