Beefy Boxes and Bandwidth Generously Provided by pair Networks
Pathologically Eclectic Rubbish Lister
 
PerlMonks  

Re^2: Algorithm::Loops::NestedLoops and LCS sequence (prune)

by hv (Prior)
on Jun 14, 2004 at 08:34 UTC ( [id://366442]=note: print w/replies, xml ) Need Help??


in reply to Re: Algorithm::Loops::NestedLoops and LCS sequence (prune)
in thread Algorithm::Loops::NestedLoops and LCS sequence

Ah, got it. I've modified the call to:

NestedLoops( [ ( sub { my $prefix = join '', @x[@_]; [ grep !$seen{$prefix . $x[$_]}++, ($_ ? $_ + 1 : @_) .. $#x ] +; } ) x $n, ], sub { my $ssx = join '', @x[@_]; $count += (matchss($ssx, $y) or return) * matchss($ssx, $x); }, );
.. and that's working fine; a dump of %seen confirms that it is seeing only genuine repeats.

Of course, now that I've unified the loop specifier, it feels slightly wasteful having to create $n copies of the same subref, but I can live with that. :)

Thanks for the help.

Hugo

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://366442]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others sharing their wisdom with the Monastery: (3)
As of 2024-04-19 22:05 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found