RosettaCodeData/Task/Odd-word-problem/Phix/odd-word-problem.phix
2017-09-25 22:28:19 +02:00

33 lines
715 B
Text

string s = "what,is,the;meaning,of:life."
--string s = "we,are;not,in,kansas;any,more."
integer i = 0
function getchar()
i += 1
return s[i]
end function
function wrod(integer rev)
integer ch = getchar(), nch
-- integer ch = getc(0), nch
if not find(ch," .,:;!?") then
if rev then
nch = wrod(rev)
end if
puts(1,ch)
if not rev then
nch = wrod(rev)
end if
ch = nch
end if
return ch
end function
--puts(1,"Enter words separated by a single punctuation mark (i.e. !?,.;:) and ending with .\n")
integer rev = 0
while 1 do
integer ch = wrod(rev)
puts(1,ch)
if ch='.' then exit end if
rev = 1-rev
end while