-------------------------------------------------------------------- -- | -- Module : Utils.Data.List -- Copyright : (c) Sigbjorn Finne, 2009 -- License : BSD3 -- -- Maintainer: Sigbjorn Finne -- Stability : provisional -- Portability: -- -------------------------------------------------------------------- module Utils.Data.List ( matchPrefix -- :: Eq a => [a] -> [a] -> Maybe [a] , transElem -- :: Eq a => a -> a -> a -> a ) where matchPrefix :: Eq a => [a] -> [a] -> Maybe [a] matchPrefix [] xs = Just xs matchPrefix (x:xs) (y:ys) | x == y = matchPrefix xs ys | otherwise = Nothing transElem :: Eq a => a -> a -> a -> a transElem t f x | t == x = f | otherwise = x