2 ms·
Actually, that problem sounds fairly well-suited to Haskell, because it's essentially a series of pure transformations. My Haskell is quite rusty, but I imagine
by nemo1618 7y ago
Actually, that problem sounds fairly well-suited to Haskell, because it's essentially a series of pure transformations. My Haskell is quite rusty, but I imagine the program would look something like:
mapM_ putStrLn $ filter startsWithNum $ lines $ readFile (args !! 0)
where startsWithNum = ...
Still, I agree with your point -- no language can be optimal for every problem.
- dllthomas 7y agoYou're printing out the line, not the number. You want `takeWhile isDigit`, followed by `filter (not . null)`.