Skip to content

Instantly share code, notes, and snippets.

@shigemk2
Created February 18, 2015 11:40
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save shigemk2/052cec9df2d9dd828a96 to your computer and use it in GitHub Desktop.
Save shigemk2/052cec9df2d9dd828a96 to your computer and use it in GitHub Desktop.
import Data.List
isIn :: (Eq a) => [a] -> [a] -> Bool
needle `isIn` haystack = any (needle `isPrefixOf`) (tails haystack)
main = do
print $ tails "party" -- ["party","arty","rty","ty","y",""]
print $ tails [1,2,3]
print $ "hawaii" `isPrefixOf` "hawaii joe"
print $ "haha" `isPrefixOf` "ha"
print $ isPrefixOf "ha" "ha"
print $ "art" `isIn` "party"
print $ "art" `isInfixOf` "party"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment