这是一个创建于 3220 天前的主题,其中的信息可能已经有所发展或是发生改变。
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