Friday, December 11, 2009

My First Haskell word in line finder

I stuck at it, and here is my finished haskell program to find all lines that contain a certain word:
findStrb :: String -> String -> Bool
findStrb key str = if key `isInfixOf` str then True else False
printList :: [String] -> IO ()
printList (x:xs) = do
putStrLn x
printList xs
main :: IO ()
main = do
infile <- readFile "ec2_list"
printList [x | x <- lines infile, findStrb "kernel" x]

No comments:

Post a Comment