4 ms·
I've posted this before on HN (see https://news.ycombinator.com/item?id=608927 https://news.ycombinator.com/item?id=608927) use List::Enumerator qw/E/;
by draegtun 13y ago
I've posted this before on HN (see https://news.ycombinator.com/item?id=608927 https://news.ycombinator.com/item?id=608927)
use List::Enumerator qw/E/;
my $fizzbuzz =
E(1)->countup
->zip(
E("", "", "Fizz")->cycle,
E("", "", "", "", "Buzz")->cycle
)
->map( sub {
my ($n, $fizz, $buzz) = @$_;
$fizz . $buzz || $n;
});
$fizzbuzz->take(20)->each(sub {
say $_;
});
The Fizzbuzz solution comes from the author of List::Enumerator CPAN module - https://metacpan.org/pod/List::Enumerator https://metacpan.org/pod/List::Enumerator