Longest common substring: Difference between revisions
Content added Content deleted
m (→{{header|Quackery}}: tweak) |
Not a robot (talk | contribs) (Add SETL) |
||
Line 2,648: | Line 2,648: | ||
"Some(Set(test))" |
"Some(Set(test))" |
||
</pre> |
</pre> |
||
=={{header|SETL}}== |
|||
<syntaxhighlight lang="setl">program longest_common_substring; |
|||
print(lcs("thisisatest", "testing123testing")); |
|||
proc lcs(s1, s2); |
|||
if #s1 < #s2 then [s1, s2] := [s2, s1]; end if; |
|||
loop for l in [#s2, #s2-1..1] do |
|||
loop for s in [1..#s2-l+1] do |
|||
if (substr := s2(s..s+l)) in s1 then |
|||
return substr; |
|||
end if; |
|||
end loop; |
|||
end loop; |
|||
return ""; |
|||
end proc; |
|||
end program;</syntaxhighlight> |
|||
{{out}} |
|||
<pre>test</pre> |
|||
=={{header|Sidef}}== |
=={{header|Sidef}}== |