A Collection of Code Snippets in as Many Programming Languages as Possible
This project is maintained by TheRenegadeCoder
Welcome to the Longest Word in Euphoria page! Here, you'll find the source code for this program as well as a description of how the program works.
include std/io.e
include std/regex.e as re
include std/text.e
include std/math.e
function longest_word(sequence s)
-- Trim off leading and trailing whitespace, then split into words
sequence words = split(re:new(`\s+`), trim(s))
-- Find longest word
integer longest = 0
for n = 1 to length(words)
do
longest = max({longest, length(words[n])})
end for
return longest
end function
procedure usage()
printf(STDOUT, "Usage: please provide a string")
abort(0)
end procedure
-- Parse 1st command-line argument
sequence argv = command_line()
if length(argv) < 4 or length(argv[4]) = 0
then
usage()
end if
-- Get longest word length and display it
sequence s = argv[4]
printf(STDOUT, "%d\n", longest_word(s))
Longest Word in Euphoria 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.