(phixonline)-->
with javascript_semantics
function lcs(sequence a, b)
sequence res = ""
if length(a) and length(b) then
if a[$]=b[$] then
res = lcs(a[1..-2],b[1..-2])&a[$]
else
sequence l = lcs(a,b[1..-2]),
r = lcs(a[1..-2],b)
res = iff(length(l)>length(r)?l:r)
end if
end if
return res
end function
constant tests = {{"1234","1224533324"},
{"thisisatest","testing123testing"}}
for i=1 to length(tests) do
string {a,b} = tests[i]
?lcs(a,b)
end for