Odd word problem: Difference between revisions

m
→‎{{header|Lua}}: minor restructure to eliminate EOF test (in case that could be considered "cheating", since period is guaranteed terminator)
(→‎{{header|Lua}}: added Lua solution)
m (→‎{{header|Lua}}: minor restructure to eliminate EOF test (in case that could be considered "cheating", since period is guaranteed terminator))
Line 1,499:
<lang lua>function reverse()
local ch = io.read(1)
if not ch then return end
if ch:find("%w") then
local rc = reverse()
Line 1,510 ⟶ 1,509:
function forward()
ch = io.read(1)
if not ch then return false end
io.write(ch)
if ch == "." then return false end
if not ch:find("%w") then
return forward()
else
ch = reverse()
if ch then io.write(ch) end
if not if ch == "." then return false end
end
return true
Line 1,524 ⟶ 1,521:
while forward() do end</lang>
{{out}}
<pre>$ echo wewhat,are;not,inis,kansasthe;anymeaning,moreof:life.|oddword.lua
what,si,the;gninaem,of:efil.
we,era;not,ni,kansas;yna,more.
 
$ echo whatwe,isare;not,in,thekansas;meaningany,of:lifemore.|oddword.lua
whatwe,siera;not,ni,thekansas;gninaemyna,of:efilmore.</pre>
 
=={{header|M2000 Interpreter}}==
Anonymous user