in reply to reduce like iterators
> and List::MoreUtils doesn't seem to provide anything better
This changed in the meantime, slide was added, but there are still issues.
The worst one is that it only returns scalars instead of lists like map does, which means we have to add an extra grep to filter undefined values :/
use v5.12; use warnings; use List::MoreUtils qw/slide/; use Data::Dump; my @x= split',', q(a,a,a,a,b,c,c,a,a,d,e,e,e,e); dd grep defined, slide { $a ne $b ? $b : () } "", @x;
Cheers Rolf
(addicted to the Perl Programming Language :)
see Wikisyntax for the Monastery
|
---|
Replies are listed 'Best First'. | |
---|---|
Re^2: reduce like iterators (BUG in List::MoreUtils::slide)
by LanX (Saint) on Jan 29, 2024 at 22:38 UTC | |
by choroba (Cardinal) on Jan 30, 2024 at 21:15 UTC | |
by LanX (Saint) on Jan 30, 2024 at 21:26 UTC |