Longest common subsequence: Difference between revisions
Content added Content deleted
(Logo) |
m (→{{header|Tcl}}: Small fixes, better organization) |
||
Line 481:
=={{header|Tcl}}==
Both solutions translated from the Java.
===Recursive===
{{works with|Tcl|8.5}}▼
▲<lang tcl>roc r_lcs {a b} {
if {$a eq "" || $b eq ""} {return ""}
set a_ [string range $a 1 end]
Line 494 ⟶ 493:
return [expr {[string length $x] > [string length $y] ? $x :$y}]
}
}</lang>
===Dynamic===
▲{{works with|Tcl|8.5}}
<lang tcl>package require Tcl 8.5
namespace import ::tcl::mathop::+
Line 535:
return [string reverse $result]
}</lang>
===Performance
<
637.5 microseconds per iteration
% time {r_lcs thisisatest testing123testing} 10
1275566.8 microseconds per iteration</
|