Longest common substring: Difference between revisions
Content added Content deleted
(→{{header|Ruby}}: Added zkl) |
(→{{header|zkl}}: bug fix) |
||
Line 209: | Line 209: | ||
<lang zkl>fcn lcd(a,b){ |
<lang zkl>fcn lcd(a,b){ |
||
if(b.len()<a.len()){ t:=a; a=b; b=t; } |
if(b.len()<a.len()){ t:=a; a=b; b=t; } |
||
foreach n,m in ([a.len()..1,-1],a.len()){ |
foreach n,m in ([a.len()..1,-1],a.len()-n+1){ |
||
s:=a[m,n]; |
s:=a[m,n]; |
||
if( |
if(b.holds(s)) return(s); |
||
} |
} |
||
"" |
|||
}</lang> |
}</lang> |
||
<lang zkl>lcd("testing123testing","thisisatest").println();</lang> |
<lang zkl>lcd("testing123testing","thisisatest").println();</lang> |