Safe Haskell | None |
---|---|
Language | Haskell2010 |
A list diff.
Documentation
diffBy :: forall a. (a -> a -> Bool) -> [a] -> [a] -> [Edit a] Source #
List difference.
>>>
diffBy (==) "hello" "world"
[Swp 'h' 'w',Swp 'e' 'o',Swp 'l' 'r',Cpy 'l',Swp 'o' 'd']
>>>
diffBy (==) "kitten" "sitting"
[Swp 'k' 's',Cpy 'i',Cpy 't',Cpy 't',Swp 'e' 'i',Cpy 'n',Ins 'g']
\xs ys -> length (diffBy (==) xs ys) >= max (length xs) (length (ys :: String))
\xs ys -> length (diffBy (==) xs ys) <= length xs + length (ys :: String)
Note: currently this has O(n*m) memory requirements, for the sake of more obviously correct implementation.