Skip to content

Instantly share code, notes, and snippets.

@patshaughnessy
Created February 11, 2014 13:19
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save patshaughnessy/8934664 to your computer and use it in GitHub Desktop.
Save patshaughnessy/8934664 to your computer and use it in GitHub Desktop.
after :: String -> [String] -> [String]
after _ [] = []
after target (x:xs)
| isInfixOf target x = [x] ++ xs
| otherwise = after target xs
main = do
contents <- readFile "the-lake-isle-of-innisfree.txt"
putStr . unlines . after "glimmer" . lines $ contents
@danchoi
Copy link

danchoi commented Feb 14, 2014

Hi Pat -- Here's my crack at it.

module Main where
import Data.List

after :: String  -- ^ match word
      -> String  -- ^ input string
      -> String
after x = unlines . dropWhile (not.isInfixOf x) . lines

main = readFile "the-lake-isle-of-innisfree.txt" >>= putStrLn . after "glimmer"

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment