Skip to content

Instantly share code, notes, and snippets.

@tst2005
Last active February 14, 2017 13:30
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tst2005/fd3a5f7446509f7802ba87ed6c41b41d to your computer and use it in GitHub Desktop.
Save tst2005/fd3a5f7446509f7802ba87ed6c41b41d to your computer and use it in GitHub Desktop.
word-rev.lua
for word,space in io.stdin:read("*l"):gmatch("(%S+)(%s*)") do
io.stdout:write( word:reverse()..space )
end
io.stdout:write("\n")
--[[--
-- $ echo 123 456-789 | lua word-rev.lua
-- 321 987-654
--]]--
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment