RosettaCodeData/Task/Longest-common-subsequence/Bracmat/longest-common-subsequence.bracmat
Ingy döt Net db842d013d A-M baby
2013-04-10 21:29:02 -07:00

13 lines
330 B
Text

( LCS
= A a ta B b tb prefix
. !arg:(?prefix.@(?A:%?a ?ta).@(?B:%?b ?tb))
& ( !a:!b&LCS$(!prefix !a.!ta.!tb)
| LCS$(!prefix.!A.!tb)&LCS$(!prefix.!ta.!B)
)
| !prefix:? ([>!max:[?max):?lcs
|
)
& 0:?max
& :?lcs
& LCS$(.thisisatest.testing123testing)
& out$(max !max lcs !lcs);