Skip Menu |
 

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

Report information
The Basics
Id: 120798
Status: open
Priority: 0/
Queue: Scalar-List-Utils

People
Owner: Nobody in particular
Requestors: zaxon [...] yopmail.com
Cc:
AdminCc:

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



Subject: request: roll function similar to that of perl6
Download (untitled) / with headers
text/plain 136b
Perl6's roll() function would be a good complement to the pick() function in git: https://github.com/Dual-Life/Scalar-List-Utils/pull/43
1.54 added "sample" which handles this -- Paul Evans
Download (untitled) / with headers
text/plain 571b
On Wed Feb 05 19:50:41 2020, PEVANS wrote: Show quoted text
> 1.54 added "sample" which handles this
it was already pointed out in the mentioned ticket that the behaviors of pick() and roll() are different: https://github.com/Dual-Life/Scalar-List-Utils/pull/43#issuecomment-577858347 perl6's roll() is similar to your implementation of sample(), but it is different from perl6's pick(): https://docs.perl6.org/type/List#routine_roll if a user wanted to emulate pick(), they'd have to call sample(1, @a) multiple times, which isn't any better than calling `map { $a[rand @a] } 1..$n`.


This service is sponsored and maintained by Best Practical Solutions and runs on Perl.org infrastructure.

Please report any issues with rt.cpan.org to rt-cpan-admin@bestpractical.com.