X.P.FuzzyMatch: Use isSubsequenceOf

The implementation is exactly the same, just that this function is now
in base, so there should be no change in behaviour.
This commit is contained in:
slotThe 2022-01-30 10:08:02 +01:00
parent 56cc296754
commit c36a888a59

View File

@ -68,10 +68,7 @@ import qualified Data.List.NonEmpty as NE
-- | Returns True if the first argument is a subsequence of the second argument,
-- that is, it can be obtained from the second sequence by deleting elements.
fuzzyMatch :: String -> String -> Bool
fuzzyMatch [] _ = True
fuzzyMatch _ [] = False
fuzzyMatch xxs@(x:xs) (y:ys) | toLower x == toLower y = fuzzyMatch xs ys
| otherwise = fuzzyMatch xxs ys
fuzzyMatch a b = isSubsequenceOf (map toLower a) (map toLower b)
-- | Sort the given set of strings by how well they match. Match quality is
-- measured first by the length of the substring containing the match and second