Skip to content

Instantly share code, notes, and snippets.

@jrm2k6
Created September 16, 2013 17:50
Show Gist options
  • Select an option

  • Save jrm2k6/6584074 to your computer and use it in GitHub Desktop.

Select an option

Save jrm2k6/6584074 to your computer and use it in GitHub Desktop.
import System.Environment (getArgs)
stringToArray :: String -> [String]
stringToArray s = words s
findLongestWord :: [String] -> String -> String
findLongestWord [] x = x
findLongestWord (w1:s1) l
| length w1 > length l = findLongestWord s1 w1
| otherwise = findLongestWord s1 l
main = do
args <- getArgs
content <- readFile (args !! 0)
let linesOfFile = lines content
map findLongestWord linesOfFile ??
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment