----- Original Message ----- From: "Janek Schleicher" <[EMAIL PROTECTED]> To: <[EMAIL PROTECTED]> Sent: Thursday, June 27, 2002 7:27 AM Subject: Re: [PROPOSAL] - List::Compare
> > I looked to the 0.11 version. > I think it would be useful to have some simple comparison methods like > List::Compare->new(\@a, \@b)->is_equal > ->is_equal_set > ->is_equal_bag > > and the equivalents isnt_equal, isnt_equal_set, isnt_equal_bag. > This would require consideration of the question: "How do I define equality?" Is the list qw(1 2 3) equal to the list qw(1 2 3 3)? I.e., "How do I treat multiple instances of the same element within a list?" Is the list ('alpha', 'beta', 'gamma') equal to the list ('alpha', 'beta gamma')? The answer depends on whether you treat whitespace as significant. Dave Cross gave consideration to these questions in the documentation to Array::Compare (http://search.cpan.org/doc/DAVECROSS/Array-Compare-1.03/Compare.pm) > Also a method which would find out > whether a list is a sublist of the other could make sense: > (I mean (2 4 6 8) is sublist of (1 2 3 4 5 6 7 8), > while (4 2 6 8) and (6 6 7 8) and (0) isn't). > .... which implies that you feel that the _order_ of elements in a list should be significant. There's no single correct answer to these questions. How you answer depends on what you need to do with the information reported by the method call. The original objective of List::Compare (with the exception of the get_bag() method) was a humble one: to put some simple object-oriented wrapping around the Cookbook code for comparison of 2 lists. The Cookbook code uses hash-lookup tables to achieve its results -- thereby flattening multiple instances and ignoring order within the lists. I would be inclined to say that any new methods added to List::Compare should take that approach, at least as their default options. At the very least, if you want to treat the order of elements as significant, you cannot use hash lookup tables to determine that; hence, you should probably look elsewhere. Thanks for taking the time to study List::Compare's documentation. Jim Keenan [EMAIL PROTECTED]