Pick random element: Difference between revisions
Content deleted Content added
→{{header|Perl 6}}: splitting the answer in a TL;DR version and a long version |
→{{header|Perl 6}}: arguably better: phrasing instead of using subsections |
||
Line 396:
=={{header|Perl 6}}==
<lang Perl 6>say (1, 2, 3).pick;</lang>
There are various ways of doing something similar, though. Perl 6 has actually two methods (with associated functional forms) to return random elements depending on whether you are doing selection with or without replacement.▼
▲Perl 6 has two methods (with associated functional forms) to return random elements depending on whether you are doing selection with or without replacement.
Selection with replacement: (roll of a die)
|