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/ordered-words.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 / ordered-words.wiki`
64 lines ยท 1491 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 note the word list (Rosetta Code reads unixdict.txt; this is a fixed sample of it), newline-terminated
8 text dict "almost\nabbey\naccent\nbegin\nbiopsy\nchimp\nchintz\ndeist\neffort\nfirst\nghost\nglory\nfloor\nknotty\nbillowy\nbijoux\nabhors\naegilops\nthis\nthat\nzebra\nbellow\nadder\ncello\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 ordered: every letter is at least the one before it
21 fn ordered a view uchar * to bool
22 for i ulong len a
23 if gt i 0
24 if lt get a i get a sub i 1
25 ret false
26 end
27 end
28 end
29 ret true
30 end
31 note two passes over the list: the longest ordered length, then every ordered word of that length
32 fn longest to ulong
33 best = ulong 0
34 s = ulong 0
35 for i ulong len dict
36 if eq get dict i 10
37 n = sub i s
38 if and ordered part dict s n gt n best
39 best = n
40 end
41 s = add i 1
42 end
43 end
44 ret best
45 end
46 fn main to int
47 best = longest
48 s = ulong 0
49 for i ulong len dict
50 if eq get dict i 10
51 n = sub i s
52 if and ordered part dict s n eq n best
53 emit part dict s add n 1
54 end
55 s = add i 1
56 end
57 end
58 ret 0
59 end
60
61 {{out}}
62
63 aegilops
64