CC: | "Michael G. Schwern" <schwern [...] pobox.com>, "Toby Inkster" <mail [...] tobyinkster.co.uk>, ilmari+cpan [...] ilmari.org, blue [...] thisisnotmyrealemail.com, smls75 [...] gmail.com, daviddlowe.flimm [...] gmail.com, "David Golden" <xdg [...] xdg.me>, ether [...] cpan.org |
Hi,
I'm currently stepping through the wishlist of LMU to see what's next.
All of you (beside xdg@ - but he has some overall perspective meanwhile) are reasonable part of a common wish for improved transformation / iteration functions:
Beside the concrete use-case functions (array_eq, ltsorted, array_map, ...) - I'd like to summon the requirements to of the central loops:
1) loops should be done with BLOCK (callback) and iterator
blockwise N, CODE, LIST
windowwise N, CODE, LIST
# (4 * 7 ^3, 5 * 3 ^ 2, 6 * 19 ^ 1)
# reduce can sum it up ...
blockwise 3 { $_[0] * $_[1] ** $_[2] } (4, 7, 3, 5, 3, 2, 6, 19, 1);
# (1,1,1,0,1,1,0)
# could be used with all for ltsorted
windowwise 2 { $_[0] < $_[1] } (1,2,3,5,4,6,8,7);
How should the iterator functions be named?
blockwise_i? chunks?
windowwise_i? magnifier?
2) the count of items per turn should be variable (always? sometimes?)
This affects pairwise only at the moment - and there it's fine.
But how can we (reasonable) add functions which does tuplewise as
tuplewise BLOCK, (LIST) x N
groupedtuplewise N, BLOCK, (LIST) x M
as
groupedtuplewise 2 { my ($g1, $g2, $g3, $g4) = @_; ($g1->[0] + $g2->[0]...) * (...$g4->[1]) } @L1, @L2, @L3, @L4
Do we want a groupedtuplewise_iter as
my $it = groupedtuplewise_iter 2 @L1, @L2, @L3, @L4;
while( my ($g1, $g2, $g3, $g4) = $it->() ) {
say ($g1->[0] + $g2->[0]...) * (...$g4->[1]);
}
3) mixin ...
while tuplewise could be a reasonable step between pairwise and chunks from multiple array at ones, how does the windowing / magnifying fit's that picture. As a reasonable consequence, there should be a function which allows accessing overlapping chunks from multiple list. Also - currently the overlapping loop has a step of one - should this increment limited to 1, or is another increment sane?
Do we want dedicated names for _step1 (eg. tuplewise vs. groupedtuplewise - or whatever ^^), or do we introduce prefixes and suffixes for that (Spreeing Helm of the Vampire)?
Cheers
Jens