Hello!

On Tue, Jun 01, 1999 at 06:58:32AM +0200, Friedrich Dominicus wrote:
> [...]

> I want to do the following, read a file line by line and finding out
> which line is longer than x-chars. I want to print out which lines are
> so long. I think that can just be done line-wise.

> Thanks for you answer I hope I got it right with that information.

longerThan :: String {- filename -} -> Int {- length limit -} -> IO ()
longerThan fn lenlim = do
    content <- readFile fn
    let li = lines content
        fl = filter (\l -> length l > lenlim) li
    putStr (unlines fl)

So, still no need to fuzz with file handles :-)

> Regards
> Friedrich

Regards, Hannah.


Reply via email to