Anonymous user
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)
io.write(ch)
if ch == "." then return false end
if not ch:find("%w") then
ch = reverse()
if ch then io.write(ch) end
end
return true
Line 1,524 ⟶ 1,521:
while forward() do end</lang>
{{out}}
<pre>$ echo
what,si,the;gninaem,of:efil.
$ echo
=={{header|M2000 Interpreter}}==
|