Longest common substring: Difference between revisions

m
(Add Cowgol)
 
(5 intermediate revisions by 4 users not shown)
Line 214:
test
</pre>
 
=={{header|APL}}==
<syntaxhighlight lang="apl">lcs←{
sb←∪⊃,/{⌽¨,\⌽⍵}¨,\⍵
match←(sb(∨/⍷)¨⊂⍺)/sb
⊃((⌈/=⊢)≢¨match)/match
}</syntaxhighlight>
{{out}}
<syntaxhighlight lang="apl">
'testing123testing' lcs 'thisisatest'
test</syntaxhighlight>
 
=={{header|AppleScript}}==
Line 1,086 ⟶ 1,097:
=={{header|EasyLang}}==
 
<syntaxhighlight lang=easylang>
func$ lcs a$ b$ .
if a$ = "" or b$ = ""
Line 1,103 ⟶ 1,114:
.
.
b$ = substr b$ 2 -19999
.
return max$
Line 1,610 ⟶ 1,621:
=={{header|langur}}==
{{trans|Julia}}
<syntaxhighlight lang="langur">val .lcs = ffn(.s1, .s2) {
var .l, .r, .sublen = 1, 0, 0
for .i of .s1 {
Line 1,838 ⟶ 1,849:
S1: string = 'thisisatest' ;
 
S2: string = 'testing123isatestingtesting123testing' ;
 
 
Line 2,410 ⟶ 2,421:
<pre>The longest common substring between 'thisisatest' and 'testing123testing' is 'test'.</pre>
 
=={{header|Refal}}==
<syntaxhighlight lang"refal">$ENTRY Go {
= <Prout <LCS ('thisisatest') 'testing123testing'>>;
};
 
LCS {
(e.X) e.L e.X e.R = e.X;
() e.Y = ;
e.X e.Y, e.X: (s.L e.XL),
e.X: (e.XR s.R)
= <Longest (<LCS (e.XL) e.Y>) <LCS (e.XR) e.Y>>;
};
 
Longest {
(e.X) e.Y, <Lenw e.X>: s.LX e.X2,
<Lenw e.Y>: s.LY e.Y2,
<Compare s.LX s.LY>: '+' = e.X;
(e.X) e.Y = e.Y;
};</syntaxhighlight>
{{out}}
<pre>test</pre>
=={{header|REXX}}==
<syntaxhighlight lang="rexx">/*REXX program determines the LCSUBSTR (Longest Common Substring) via a function. */
Line 2,857 ⟶ 2,889:
=={{header|Wren}}==
{{trans|Go}}
<syntaxhighlight lang="ecmascriptwren">var lcs = Fn.new { |a, b|
var la = a.count
var lb = b.count
885

edits