Re: Tie::Array::Sorted
* Orton, Yves yves.orton at de.mci.com [2003-11-12 17:00]: /me feels silly Ach, dont be. The main reason I feel silly is that I just used Tie::IxHash yesterday. I just never made the connection... (darren) -- There is not enough love in the world to squander it on anything by human beings. pgp0.pgp Description: PGP signature
Re: Tie::Array::Sorted
Randy W. Sims: Sounds like a set/multiset/bag structure. I thought it sounded more like a sorted array, but I'm prepared to be persuaded otherwise. (Primarily because I've already released the module to CPAN. ;) http://search.cpan.org/search?query=Setmode=all Which of those were you thinking of? None of them seem to be obviously related. -- `After all, we're not all freaky perverts' - Thorfinn
Re: Tie::Array::Sorted
Randy W. Sims: Hmm, Jarkko has a nice set (err, no not those), but (and no not that either) your module is the only one I see that uses a tied array to implement a set; Sorry, I should have been more explicit. I can't see any connection between keeping something *sorted* specifically and having a set. And, no, I don't plan to add set operations. This is a module for keeping an array sorted. There are plenty of modules which handle sets, but this is not one of them. -- Rule 3: If the character is comprised of a container without another radical, then Rule 3 will not apply.
Re: Tie::Array::Sorted
* Randy W. Sims [EMAIL PROTECTED] [2003-11-13 16:32]: Hmm, Jarkko has a nice set (err, no not those), but (and no not that either) [ ... ] Randy. Your name is very appropriate. :-) -- Regards, Aristotle If you can't laugh at yourself, you don't take life seriously enough.
Re: Tie::Array::Sorted
Simon Cozens writes: I can't see any connection between keeping something *sorted* specifically and having a set. I think it depends what you're doing with duplicates. I haven't looked at your module, but if you are leaving duplicate values in there (consecutively, presumably) then I'm pretty sure it definitely isn't a set. 'The set of all the numbers of houses I've ever lived at' doesn't contain any duplicates, even if I've lived at both 7 Argumentative Avenue and 7 Quarrel Grove. Smylers
Re: Tie::Array::Sorted
* at 13/11 17:16 + Fergal Daly said: On Wed, Nov 12, 2003 at 05:17:28PM +, Simon Cozens wrote: Randy W. Sims: Sounds like a set/multiset/bag structure. I thought it sounded more like a sorted array, but I'm prepared to be persuaded otherwise. (Primarily because I've already released the module to CPAN. ;) I think the point is that T::S::A is closer to a set than an array, or more to the point it's interace is just an expansion of a Set's interface. Whereas it is a restriction of an array's interface - well it doesn't have to be a restriction but as you point out in the docs, using the full array interface doesn't make sense and for instance snip lots of things about sets However, if I am looking for a module that makes it easy for me to have a sorted array I am not going to look at modules with Set in the name. I'd wager a lot of people aren't either given that for most people a set is a rather obscure concept that they probably regard as having something to do with maths and maths scares people even more than computers ;). Accuracy in module names is all very well but when it comes at the cost of actually describing what they are to be used for then it's not a price worth paying. cheers Struan
Re: Tie::Array::Sorted
[EMAIL PROTECTED] (Struan Donald) writes: However, if I am looking for a module that makes it easy for me to have a sorted array I am not going to look at modules with Set in the name. The module's already uploaded, guys; the thread is dead. -- There seems no plan because it is all plan. -- C.S. Lewis
RE: Tie::Array::Sorted
Title: RE: Tie::Array::Sorted * Simon Cozens simon at simon-cozens.org [2003-11-12 13:32]: Is Tie::Array::Sorted a reasonable name for it, or would another one be more obvious? DB_File has a way to do this iirc. But it is a shocking ommission if there isnt at least one other way. I definately vote for Tie::Array::Sorted, but It may be worth having a look at Tie::Hash::Sorted and make them compatible on some level. This seems a reasonable name. Is there also a hash version in the works? I write: for my $key (sort keys %h) { ... often enough that I would use it. Tie::Hash::Sorted (http://search.cpan.org/~jgatcomb/Tie-Hash-Sorted-0.10/Sorted.pm) Tie::IxHash (http://search.cpan.org/author/GSAR/Tie-IxHash-1.21/lib/Tie/IxHash.pm) Tie::Hash::Array (http://search.cpan.org/author/FANY/Tie-Hash-Array-0.01/lib/Tie/Hash/Array.pm) Tie::SortHash (http://search.cpan.org/author/CTWETEN/Tie-SortHash-1.01/SortHash.pm) :-) Yves
Re: Tie::Array::Sorted
Simon Cozens wrote: Hi. I'm about to write a module which presents an array in sorted order; $a[0] will always be the least element by some comparator. Miraculously, there doesn't seem to be such a beast on CPAN already. Is Tie::Array::Sorted a reasonable name for it, or would another one be more obvious? Sounds like a set/multiset/bag structure. http://search.cpan.org/search?query=Setmode=all Regards, Randy.
Re: Tie::Array::Sorted
RE: Tie::Array::SortedHi Simon and others, I agree that Tie::Array::Sorted is a good name. But it is a shocking ommission if there isnt at least one other way. I definately vote for Tie::Array::Sorted, but It may be worth having a look at Tie::Hash::Sorted and make them compatible on some level. And I agree that Tie::Array::Sorted should be compatible with Hash::Sorted in some level. But I wouldn´t like if Tie::Array worked just like Hash::Sorted because I don´t like it. With Hash::Sorted we still have to know that enigmatic sorting subroutine: my $sort_by_numeric_value = sub { # this sub sucks!! my $hash = shift; [ sort {$hash-{$b} = $hash-{$a}} keys %$hash ]; }; This is the difficult part that should be encapsulated, i think. I suggest that you implement something like an ORDER attribute with the values ASCENDING and DESCENDING, sparing us to know about that subroutine. like this: tie my @sorted_array, 'Tie::Array::Sorted', 'Array' = \ @unsorted_array, 'ORDER' = ASCENDING; Also, you could try to guess (via regexps) if the data to be sorted is numeric or alphabetical and use the appropriate subrouting to order it. But if you don´t think this is a good idea, you could add another attribute called TYPE with the values NUMERIC and ALPHABETICAL. see ya, bnegrao.
Re: Tie::Array::Sorted
* Bruno Negrao [EMAIL PROTECTED] [2003-11-12 18:47]: Also, you could try to guess (via regexps) if the data to be sorted is numeric or alphabetical and use the appropriate subrouting to order it. Bleah. This kind of second-guessing easily leads to surprises. Being explicit is good. -- Regards, Aristotle If you can't laugh at yourself, you don't take life seriously enough.
Re: Tie::Array::Sorted
On Wed, Nov 12, 2003 at 09:42:05PM +, Nicholas Clark wrote: On Wed, Nov 12, 2003 at 10:16:51PM +0100, Paul Johnson wrote: On Wed, Nov 12, 2003 at 01:32:13PM +, Simon Cozens wrote: Hi. I'm about to write a module which presents an array in sorted order; $a[0] will always be the least element by some comparator. Miraculously, there doesn't seem to be such a beast on CPAN already. Is Tie::Array::Sorted a reasonable name for it, or would another one be more obvious? s/Tie::// ? Do I need to be concerned with how the module is implemented? Presumably the documentation will tell me how to use it. Yes, this probably applies to the rest of the Tie:: namespace too. Oh, I was going to say this. Tie::Array::Sorted is a good name because it is consistent with many other modules. But I consider them all to be misnamed. The implementation is not the most important feature of these modules - why is it the most important part of their names? I disagree. The Tie:: doesn't just describe the implementation, it describes the interface. And that's often a key aspect of modules that offer functionality behind a tie interface. Given a choice between Array::Sorted and Tie::Array::Sorted I'd know that Tie::Array::Sorted provides a tie interface and so will, for example, let me pass a ref to the array to code I don't control and still get the behaviour I want. Tim.