这是一个创建于 3198 天前的主题,其中的信息可能已经有所发展或是发生改变。
import Data.Char (isDigit)
longestInts :: String -> [Int]
longestInts xs = map (digitsToInt) $ longestLength $ extractDigits xs
extractDigits :: String -> [String]
extractDigits [] = []
extractDigits xs
| null $ dropWhile (not.isDigit) xs = []
| otherwise = (takeWhile (isDigit) $ dropWhile (not.isDigit) xs) : (extractDigits $ dropWhile (isDigit) $ dropWhile (not.isDigit) xs)
longestLength :: [[a]] -> [[a]]
longestLength xs = filter (\x -> length x == (maximum $ map (length) xs)) xs