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/reverse-words-in-a-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 / reverse-words-in-a-string.wiki`
75 lines ยท 1626 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 sp " "
8 text poem "---------- Ice and Fire ------------\n\nfire, in end will world the say Some\nice. in say Some\ndesire of tasted I've what From\nfire. favor who those with hold I\n\n... elided paragraph last ...\n\nFrost Robert -----------------------\n"
9 note emit writes every byte of a to stdout; a short write is retried, an error exits 1
10 fn emit a view uchar * to void
11 o = ulong 0
12 while lt o len a bound 4096
13 k = write 1 a o sub len a o
14 if le k 0
15 exit 1
16 end
17 o = add o ulong k
18 end
19 end
20 note revline prints the space-separated words of a in reverse order, one space between them
21 fn revline a view uchar * to void
22 st = new ulong 64 0
23 ln = new ulong 64 0
24 k = ulong 0
25 i = ulong 0
26 while lt i len a bound 4096
27 if eq get a i 32
28 i = add i 1
29 else
30 j = i
31 while lt j len a bound 4096
32 if eq get a j 32
33 break
34 end
35 j = add j 1
36 end
37 put st k i
38 put ln k sub j i
39 k = add k 1
40 i = j
41 end
42 end
43 for w ulong k
44 if gt w 0
45 emit sp
46 end
47 x = sub sub k 1 w
48 emit part a get st x get ln x
49 end
50 emit nl
51 end
52 fn main to int
53 s = ulong 0
54 for i ulong len poem
55 if eq get poem i 10
56 revline part poem s sub i s
57 s = add i 1
58 end
59 end
60 ret 0
61 end
62
63 {{out}}
64
65 ------------ Fire and Ice ----------
66
67 Some say the world will end in fire,
68 Some say in ice.
69 From what I've tasted of desire
70 I hold with those who favor fire.
71
72 ... last paragraph elided ...
73
74 ----------------------- Robert Frost
75