%!PS % begin included library code % see https://codeberg.org/Firedrake/postscript-libraries/ /s2a { [ exch { } forall ] } bind def /a2s { 2 dict begin /i exch def i length dup string /o exch def 1 sub 0 exch 1 exch { dup i 3 -1 roll get o 3 1 roll put } for o end } bind def /filter { % array proc(bool) -> array 1 dict begin /p exch def [ exch { dup p not { pop } if } forall ] end } bind def /test.start { print (:) print /test.pass 0 def /test.count 0 def } bind def /test.end { ( ) print test.count 0 gt { (Passed ) print test.pass (...) cvs print (/) print test.count (...) cvs print ( \() print test.pass 100 mul test.count idiv (...) cvs print (%\)) print (\r\n) print } if } bind def /test { /test.count test.count 1 add def { /test.pass test.pass 1 add def } { ( ) print test.count (....) cvs print (-fail) print } ifelse } bind def /toupper { s2a [ exch { dup dup 97 ge exch 122 le and { 32 sub } if } forall ] a2s } bind def /tolower { s2a [ exch { dup dup 65 ge exch 90 le and { 32 add } if } forall ] a2s } bind def % end included library code /is_vowel { << 65 true 69 true 73 true 79 true 85 true 97 true 101 true 105 true 111 true 117 true >> exch known } bind def /reversevowels { 0 dict begin /p exch s2a def /q p { is_vowel } filter def /qi q length def [ p { /c exch def c is_vowel { /qi qi 1 sub def /nc q qi get def c 65 ge c 90 le and { 1 string dup 0 nc put toupper 0 get /nc exch def } { c 97 ge c 122 le and { 1 string dup 0 nc put tolower 0 get /nc exch def } if } ifelse nc } { c } ifelse } forall ] a2s end } bind def (reversevowels) test.start (Raku) reversevowels (Ruka) eq test (Perl) reversevowels (Perl) eq test (Julia) reversevowels (Jaliu) eq test (Uiua) reversevowels (Auiu) eq test test.end