|
Warning: this is an htmlized version!
The original is here, and the conversion rules are here. |
-- (find-sh0 "echo 'foo\nfoobar' | rexx pig.rexx")
-- (defun c0 () (interactive) (find-sh0 "echo 'foo\nfoobar' | rexx pig.rexx"))
rule = copies('-', 20)
say rule
say ' Pig Latin'
say rule
say
do forever
input = prompt("? ")
if input = '' then leave
call backslang input
say ":" result
end
exit 0
backslang: procedure
parse arg input
sentence = ''
do w=1 to words(input)
call word input, w
word = filter(result, ',.;:!''"?')
select
-- Special cases:
when word = 'a' then latin = 'ay'
-- Latinate!
otherwise do
hinge = verify(lower(word), 'aeiou', 'M')
latin = substr(word, hinge)substr(word, 1, hinge-1)'ay'
end
end
sentence = sentence latin
end
return strip(sentence)
prompt: procedure
call charout , "? "
parse pull input
return input
-- Like a global strip()
filter: procedure
parse arg input, illicit
do forever
call verify input, illicit, 'M'
if result = 0 then leave
input = delstr(input, result, 1)
end
return input