Yacoby read, , head/tail read . , head, . ,
get3rd :: String -> String
get3rd s =
case (take 3 $ words s) of
[_,_,w] -> w
otherwise -> ""
( , 3 ). , , , head/tail.
read ( ), reads :
toInt :: String -> Maybe Int
toInt s =
case reads s of
[(i,_)] -> Just i
otherwise -> Nothing
-- test cases
main = do
print . toInt . get3rd $ "1 2 3"
print . toInt . get3rd $ "one two three"
print . toInt . get3rd $ "short list"
toInt Just Nothing, . readMay.