Skip Menu |

This queue is for tickets about the List-MoreUtils CPAN distribution.

Report information
The Basics
Id: 19024
Status: open
Priority: 0/
Queue: List-MoreUtils

People
Owner: Nobody in particular
Requestors: DarGo [...] sPam.lA
mschwern [...] cpan.org
Cc:
AdminCc:

Bug Information
Severity: Wishlist
Broken in: (no value)
Fixed in: (no value)



Subject: wishlist: ltsorted, gtsorted
implement test functions $a < $b < $c and $a > $b > $c , etc. for large lists these functions would be more efficient than creating a sorted copy and comparing the two lists.
Subject: WG: [rt.cpan.org #19024] wishlist: ltsorted, gtsorted
Date: Wed, 03 May 2006 07:46:03 -0400
To: bug-List-MoreUtils [...] rt.cpan.org
From: Tassilo von Parseval <Tassilo.von.Parseval [...] rwth-aachen.de>
Hi there, Show quoted text
----- Originalnachricht ----- Von: Guest via RT <bug-List-MoreUtils@rt.cpan.org> Datum: Montag, Mai 1, 2006 11:09 pm Betreff: [rt.cpan.org #19024] wishlist: ltsorted, gtsorted
> > Mon May 01 23:09:10 2006: Request 19024 was acted upon. > Transaction: Ticket created by guest > Queue: List-MoreUtils > Subject: wishlist: ltsorted, gtsorted > Owner: Nobody > Requestors: DarGo@sPam.lA > Status: new > Ticket <URL: http://rt.cpan.org/Ticket/Display.html?id=19024 > > > > implement test functions $a < $b < $c and $a > $b > $c , etc. for > largelists these functions would be more efficient than creating a > sortedcopy and comparing the two lists.
So if I get you correctly, these are functions that, given a list, return true if the list is sorted in the given order (lt or gt)? I've added it to the to-do list. Note however that it may take me a couple of months before I can make new CPAN releases as I've just started a new job in NYC and don't yet have a computer (other than the ones on the job which I can't use for CPAN uploads). Cheers, Tassilo
Subject: Operate on a sliding set of pairs
I'm finding myself in need of a function to do operation on pairs of elements in a list like so: 0 and 1 1 and 2 2 and 3 3 and 4 and so on For example... # 0 and 1, 1 and 2, 2 and 3. print join ", ", slide { "$a and $b" } (0, 1, 2, 3); This would be useful for performing operations *between* two elements in a list. It replaces loops like this: my $last_thing; for my $thing (@things) { return $last_thing if $thing > $blah; $last_thing = $thing; } With this: my $thing; slide { $thing = $a if $b > $blah } @things; It would be nice to avoid having a whole set of these functions (grep, map, first, etc...) by perhaps having an iterator which can generate pairs without having to create a double side list. my $slider = make_slider \@things; while( my($a, $b) = $slider->next ) { ... } This may be out of scope for List::MoreUtils.
If I could add my two cents: I suggest functions 'sorted' (which does a 'cmp' comparison) and 'sorted_num' (which uses <=>). Testing for reverse order can be done as sorted(reverse @a) so it is probably not necessary to add a separate function.
Or: sub sorted (&@) { ...; } sub sorted_numerically { unshift @_, sub { $a <=> $b }; goto \&sorted; } sub sorted_alphabetically { unshift @_, sub { $a cmp $b }; goto \&sorted; }
This is a reasonable base function as tobyink showed up for RT#19024's wish ...
I know it's a while open ... but can you guys check whether the qsort BLOCK, ARRAY function does the job for you? Please keep in mind - this will never work reasonably for pure-perl.
On Wed Aug 23 05:55:50 2017, REHSACK wrote:
Show quoted text
> I know it's a while open ... but can you guys check whether the qsort
> BLOCK, ARRAY function does the job for you?

That's a neat function, but my request for a "slide" function seems to have been lumped in here by mistake.
On Wed Aug 23 17:06:11 2017, MSCHWERN wrote: Show quoted text
> On Wed Aug 23 05:55:50 2017, REHSACK wrote:
> > I know it's a while open ... but can you guys check whether the qsort > > BLOCK, ARRAY function does the job for you?
> > That's a neat function, but my request for a "slide" function seems to have > been lumped in here by mistake.
Oh yeah - but it looks cool. I'll put on on top of new functions ...