Skip to content

Instantly share code, notes, and snippets.

@shigemk2 shigemk2/haystack.hs
Created Feb 18, 2015

Embed
What would you like to do?
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
You can’t perform that action at this time.