Created
February 18, 2015 11:40
-
-
Save shigemk2/052cec9df2d9dd828a96 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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