10 lines
402 B
Text
10 lines
402 B
Text
table
|
|
lcs_rule(A, B) = "", (A == ""; B == "") => true.
|
|
lcs_rule(A, B) = [A[1]] ++ lcs_rule(butfirst(A), butfirst(B)), A[1] == B[1] => true.
|
|
lcs_rule(A, B) = longest(lcs_rule(butfirst(A), B), lcs_rule(A, butfirst(B))) => true.
|
|
|
|
% Return the longest string of A and B
|
|
longest(A, B) = cond(A.length > B.length, A, B).
|
|
|
|
% butfirst (everything except first element)
|
|
butfirst(A) = [A[I] : I in 2..A.length].
|