X-Git-Url: http://git.megacz.com/?a=blobdiff_plain;f=Data%2FList.hs;h=cc166d80de94e3bb57cca73937cd1376d043a6fc;hb=7b2cb5626544e89431b8fbc42ab3eca072913b23;hp=3c9fd265958bf8d8cbc5e0518510dcf42312de69;hpb=a1caf8ef316aafbd2d75ce56ccfa85af8ac77f96;p=ghc-base.git diff --git a/Data/List.hs b/Data/List.hs index 3c9fd26..cc166d8 100644 --- a/Data/List.hs +++ b/Data/List.hs @@ -230,10 +230,10 @@ infix 5 \\ -- comment to fool cpp -- It returns 'Nothing' if the list did not start with the prefix -- given, or 'Just' the list after the prefix, if it does. -- --- > stripPrefix "foo" "foobar" -> Just "bar" --- > stripPrefix "foo" "foo" -> Just "" --- > stripPrefix "foo" "barfoo" -> Nothing --- > stripPrefix "foo" "barfoobaz" -> Nothing +-- > stripPrefix "foo" "foobar" == Just "bar" +-- > stripPrefix "foo" "foo" == Just "" +-- > stripPrefix "foo" "barfoo" == Nothing +-- > stripPrefix "foo" "barfoobaz" == Nothing stripPrefix :: Eq a => [a] -> [a] -> Maybe [a] stripPrefix [] ys = Just ys stripPrefix (x:xs) (y:ys) @@ -297,12 +297,12 @@ isSuffixOf x y = reverse x `isPrefixOf` reverse y -- -- Example: -- --- >isInfixOf "Haskell" "I really like Haskell." -> True --- >isInfixOf "Ial" "I really like Haskell." -> False +-- >isInfixOf "Haskell" "I really like Haskell." == True +-- >isInfixOf "Ial" "I really like Haskell." == False isInfixOf :: (Eq a) => [a] -> [a] -> Bool isInfixOf needle haystack = any (isPrefixOf needle) (tails haystack) --- | The 'nub' function removes duplicate elements from a list. +-- | /O(n^2)/. The 'nub' function removes duplicate elements from a list. -- In particular, it keeps only the first occurrence of each element. -- (The name 'nub' means \`essence\'.) -- It is a special case of 'nubBy', which allows the programmer to supply