diff --git a/lib/Data/List.hs b/lib/Data/List.hs index 354c7166..5c464ac5 100644 --- a/lib/Data/List.hs +++ b/lib/Data/List.hs @@ -336,7 +336,7 @@ isInfixOf :: forall a . Eq a => [a] -> [a] -> Bool isInfixOf = isInfixOfBy (==) isInfixOfBy :: forall a . (a -> a -> Bool) -> [a] -> [a] -> Bool -isInfixOfBy eq cs ds = any (isPrefixOfBy eq cs) (inits ds) +isInfixOfBy eq cs ds = any (isPrefixOfBy eq cs) (tails ds) splitAt :: forall a . Int -> [a] -> ([a], [a]) splitAt n xs = (take n xs, drop n xs) diff --git a/tests/ListTest.hs b/tests/ListTest.hs index 6776b108..0f962b47 100644 --- a/tests/ListTest.hs +++ b/tests/ListTest.hs @@ -1,9 +1,11 @@ module ListTest(module ListTest) where -import Prelude + +import Data.List main :: IO () main = do - putStrLn $ show $ sum [1,2,3::Int] - putStrLn $ show $ product [1,2,3,4::Int] - putStrLn $ show $ and [True] - putStrLn $ show $ and [True, False] + print $ sum [1, 2, 3 :: Int] + print $ product [1, 2, 3, 4 :: Int] + print $ and [True] + print $ and [True, False] + print $ [2] `isInfixOf` [1, 2, 3 :: Int] diff --git a/tests/ListTest.ref b/tests/ListTest.ref index dec1f87f..464add01 100644 --- a/tests/ListTest.ref +++ b/tests/ListTest.ref @@ -2,3 +2,4 @@ 24 True False +True