interplane.Get Omega
Read in your language

omega-rosetta

aien-dev/omega-rosetta

Brought by drakestapleton

branch main Branches Tags History

omega-rosetta / exercises / acronym / .meta / example.om

28 lines · 690 bytes Raw Blame History
1note Exercism-style exercise "acronym": https://exercism.org/tracks/python/exercises/acronym
2note SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
3note abbreviate writes the upper-case acronym of phrase s into o and returns its length. Words are
4note separated by spaces, hyphens and other punctuation; an apostrophe does not start a new word.
5note Check it with: sh exercise.sh exercises/acronym
6om2
7fn abbreviate s view uchar * o edit uchar * to ulong
8p = ulong 0
9prev = false
10for i ulong len s
11c = get s i
12up = and ge c 65 le c 90
13lo = and ge c 97 le c 122
14if or up lo
15if not prev
16if lo
17c = sub c 32
18end
19put o p c
20p = add p 1
21end
22prev = true
23else
24prev = eq c 39
25end
26end
27ret p
28end