Friedrich Dominicus wrote: > That might be good advice but I/O is one of the most essential things > and I have to know how to use it proper for writing small skripts. Actually, you can do a lot without learning about I/O. The function `interact' converts a `String->String' function into an IO function which can be used at the top level. Here are some simple examples: -- Just copy stdin to stdout main = interact id -- Remove all Q from stdin main = interact (filter (/= 'Q')) -- Print the line number in front of each line main = interact (unlines . zipWith (\n l -> show n ++ " " ++ l) [1..] . lines) -- Print a sorted list of all words import List main = interact (unlines . nub . sort . concatMap words . lines) Well, I'm sure you get the idea. -- Lennart
- Re: how to write a simple cat Hans Aberg
- Re: how to write a simple cat Laszlo Nemeth
- Re: how to write a simple cat Hannah Schroeter
- Re: how to write a simple cat Mariano Suarez-Alvarez
- Re: how to write a simple cat Hans Aberg
- Re: how to write a simple cat Hannah Schroeter
- Re: how to write a simple cat Friedrich Dominicus
- Re: how to write a simple cat Friedrich Dominicus
- Re: how to write a simple cat Mariano Suarez-Alvarez
- Re: how to write a simple cat Hans Aberg
- Re: how to write a simple cat Lennart Augustsson
- Re: how to write a simple cat Friedrich Dominicus
- Re: how to write a simple cat Christoph Lueth
- Re: how to write a simple cat Hannah Schroeter
- Re: how to write a simple cat Hannah Schroeter
- Re: how to write a simple cat Hannah Schroeter
- Re: how to write a simple cat Friedrich Dominicus
- Re: how to write a simple cat Friedrich Dominicus
- Re: how to write a simple cat Rainer Joswig
- Re: how to write a simple cat Fergus Henderson
- RE: how to write a simple cat Frank A. Christoph