Longest common subsequence: Difference between revisions
Content added Content deleted
Alextretyak (talk | contribs) (Added 11l) |
(Added Wren) |
||
Line 3,193: | Line 3,193: | ||
{{out}} |
{{out}} |
||
<pre>'tsitest'</pre> |
<pre>'tsitest'</pre> |
||
=={{header|Wren}}== |
|||
{{trans|Kotlin}} |
|||
<lang ecmascript>var lcs // recursive |
|||
lcs = Fn.new { |x, y| |
|||
if (x.count == 0 || y.count == 0) return "" |
|||
var x1 = x[0...-1] |
|||
var y1 = y[0...-1] |
|||
if (x[-1] == y[-1]) return lcs.call(x1, y1) + x[-1] |
|||
var x2 = lcs.call(x, y1) |
|||
var y2 = lcs.call(x1, y) |
|||
return (x2.count > y2.count) ? x2 : y2 |
|||
} |
|||
var x = "thisisatest" |
|||
var y = "testing123testing" |
|||
System.print(lcs.call(x, y))</lang> |
|||
{{out}} |
|||
<pre> |
|||
tsitest |
|||
</pre> |
|||
=={{header|zkl}}== |
=={{header|zkl}}== |