blob: 74dba95da4e64aafcfca17037e0af401755cdf2b (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
|
#!/usr/bin/env -S nim r -d:release --verbosity:0 --hints:off
import std/[strutils, sugar]
const Vowels = {'a','e','i','o','u'}
proc reversedVowels*(s: string): string =
let vowels = collect:
for i in countDown(s.high, 0):
let c = s[i].toLowerAscii
if c in Vowels: c
result = s
var ind = 0
for c in result.mItems:
if c.toLowerAscii in Vowels:
c = if c.isUpperAscii: vowels[ind].toUpperAscii else: vowels[ind]
inc ind
when isMainModule:
import std/unittest
suite "required tests":
test "Raku":
check reversedVowels("Raku") == "Ruka"
test "Perl":
check reversedVowels("Perl") == "Perl"
test "Julia":
check reversedVowels("Julia") == "Jaliu"
test "Uiua":
check reversedVowels("Uiua") == "Auiu"
|