Compute a longest common subsequence between two lists. Elements can be compared by means of an arbitrary similarity metric.
A
and B
are can be common if A==B
.
Implemented in terms of lcs/5.
A-B
since Cmp allows non-identical
elements to be considered common.
Elements of As and Bs are compared by call(Cmp,A,B,Similarity)
,
where larger Similarity
values indicate more similar elements.
Length is the sum of similarity scores for elements in the
subsequence.
Implemented with memoization on top of a naive, exponential algorithm. It performs fairly well, but patches to use a better algorithm are welcome.
A == B
, otherwise 0. This predicate
is helpful as the first argument to lcs/5.