A Collection of Code Snippets in as Many Programming Languages as Possible
This project is maintained by TheRenegadeCoder
Welcome to the Longest Word in Lua page! Here, you'll find the source code for this program as well as a description of how the program works.
if #arg < 1 then
print("Usage: please provide a string")
os.exit(1)
end
local input = arg[1]
function longest_word_length(str)
local max_length = 0
local found_word = false
for word in string.gmatch(str, "%S+") do
found_word = true
local length = #word
if length > max_length then
max_length = length
end
end
if not found_word then
print("Usage: please provide a string")
os.exit(1)
end
return max_length
end
print(longest_word_length(input))
Longest Word in Lua was written by:
If you see anything you'd like to change or update, please consider contributing.
No 'How to Implement the Solution' section available. Please consider contributing.
No 'How to Run the Solution' section available. Please consider contributing.