Beefy Boxes and Bandwidth Generously Provided by pair Networks
more useful options
 
PerlMonks  

Re: Algorithm::Diff icult to use

by RMGir (Prior)
on Aug 21, 2002 at 11:21 UTC ( [id://191693]=note: print w/replies, xml ) Need Help??


in reply to Algorithm::Diff icult to use

Nice!

Why one list, though? Wouldn't a LoL be simpler to use AND easily let the user see how many ranges there are? Well, I guess they can do scalar(@diff)/5, but that doesn't seem as intuitive.

I don't know if the sublists would cause too much memory overhead, but it shouldn't be anywhere near as bad as the problem you cite with A::Diff.

That's just a nit; it's nice and clean, and quite useable as is.
--
Mike

Edit: Hmmm, nevermind. I guess if I want an LoL I can just do

my @diff2; while(@diff) { push @diff2,[splice @diff,0,5]; }

Replies are listed 'Best First'.
Re: Re: Algorithm::Diff icult to use
by bart (Canon) on Aug 21, 2002 at 17:25 UTC
    Hmmm, nevermind.

    Actually, I agree with your LoL remark. Returning a flat list seems too low level. Plus, if for any reason a new field needs to be added, so the number is no longer 5, it would break all code using it.

    Modified, the code could look like:

    my $diff= easy( \@a, \@b ); foreach ( @$diff ) { my( $same, $aMin, $aMax, $bMin, $bMax )= @$_; ... # rest of code snipped because unaltered }

    or

    my $diff= easy( \@a, \@b ); while (my $row = shift @$diff ) { my( $same, $aMin, $aMax, $bMin, $bMax )= @$row; ... # rest of code snipped because unaltered }

    Never mind the extra overhead (if any)... No?

      Makes sense. You're right that "5" hardwired everywhere could cause trouble...

      Oh, and I like your foreach better than the shift approach. It's probably faster, and it's what foreach is for. :)
      --
      Mike

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others meditating upon the Monastery: (4)
As of 2024-04-25 17:07 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found