Longest common subsequence: Difference between revisions

no edit summary
m (→‎{{header|Tcl}}: Small fixes, better organization)
No edit summary
Line 328:
end
</lang>
 
=={{header|Mathematica}}==
A built-in function can do this for us:
<lang Mathematica>
a = "thisisatest";
b = "testing123testing";
LongestCommonSequence[a, b]
</lang>
gives:
<lang Mathematica>tsitest</lang>
Note that Mathematica also has a built-in function called LongestCommonSubsequence[a,b]:
 
''finds the longest contiguous subsequence of elements common to the strings or lists a and b.''
 
which would give "test" as the result for LongestCommonSubsequence[a, b].
 
The description for LongestCommonSequence[a,b] is:
 
''finds the longest sequence of contiguous or disjoint elements common to the strings or lists a and b.''
 
I added this note because the name of this article suggests LongestCommonSubsequence does the job, however LongestCommonSubsequence performs the puzzle-description.
 
 
=={{header|OCaml}}==
1,111

edits