in reply to Re: reduce like iterators
in thread reduce like iterators

> 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 :/

That's most likely a bug in the XS implementation of slide.

I looked into the Pure Perl implementation in List::MoreUtils::PP, and it looked fine, it's literally using map

And a test reveals, that it really works like it should.

use v5.12; use warnings; use Data::Dumper; BEGIN { $ENV{LIST_MOREUTILS_PP} = 1 }; # enforce PP version, comment f +or XS use List::MoreUtils qw/slide/; my @x= split',', q(a,a,a,a,b,c,c,a,a,d,e,e,e,e); print Dumper 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^3: reduce like iterators (BUG in List::MoreUtils::slide)
by choroba (Cardinal) on Jan 30, 2024 at 21:15 UTC
    > That's most likely a bug in the XS implementation of slide.

    The word "bug" should be a link to the actual bug report.

    map{substr$_->[0],$_->[1]||0,1}[\*||{},3],[[]],[ref qr-1,-,-1],[{}],[sub{}^*ARGV,3]
      I already reported it in private, it's complicated....

      Cheers Rolf
      (addicted to the Perl Programming Language :)
      see Wikisyntax for the Monastery