Longest common subsequence: Difference between revisions

m
→‎header/Perl: future-proof for 5.36, use new bitwise string operator
m (Swapped order of two paragraphs.)
m (→‎header/Perl: future-proof for 5.36, use new bitwise string operator)
Line 2,151:
 
===Alternate letting regex do all the work===
<syntaxhighlight lang="perl">#!/usr/bin/perluse strict;
 
use strict; # https://rosettacode.org/wiki/Longest_common_subsequence
use warnings;
use feature 'bitwise';
 
print "lcs is ", lcs('thisisatest', 'testing123testing'), "\n";
Line 2,161 ⟶ 2,160:
{
my ($c, $d) = @_;
for my $len ( reverse 1 .. length($c &. $d) )
{
"$c\n$d" =~ join '.*', ('(.)') x $len, "\n", map "\\$_", 1 .. $len and
Line 2,169 ⟶ 2,168:
}</syntaxhighlight>
{{out}}
<pre>lcs is tsitesttastiest</pre>
 
=={{header|Phix}}==
2,392

edits