How can I find the longest subsequences that two lists have in common? For example:
["abcdefg", "abc__fg", "ab____g"]
It should return:
["ab", "g"]
Is there an existing function that does this? How would you compose one from existing ones?
You're looking for Data.List.CommonSubstring
$ ghci
λ: :m +Data.List.CommonSubstring
λ: longestSubstring "abcdefg" "abc__fg"
"abc"
It's unclear what exactly you want (longest subsequence or all possible subsequences), so feel free to use Data.SuffixTree directly to implement required logic.
Collected from the Internet
Please contact [email protected] to delete if infringement.
Comments