Generate random numbers without repeating a value: Difference between revisions
Generate random numbers without repeating a value (view source)
Revision as of 20:55, 27 August 2021
, 2 years ago→{{header|Factor}}: change wording
(→{{header|Factor}}: add some different approaches) |
m (→{{header|Factor}}: change wording) |
||
Line 30:
=={{header|Factor}}==
Generating a random permutation of 1..
{{works with|Factor|0.99 2021-06-02}}
<lang factor>USING: kernel math.combinatorics math.ranges prettyprint random
Line 43:
{ 7 10 12 9 5 8 20 14 18 4 13 3 17 16 19 6 15 1 2 11 }
</pre>
Shuffling 1..
{{works with|Factor|0.99 2021-06-02}}
<lang factor>USING: math.ranges prettyprint random vectors ;
Line 52:
V{ 20 7 8 17 18 1 15 13 12 10 3 14 19 2 5 9 16 11 6 4 }
</pre>
Sampling n elements from 1..
{{works with|Factor|0.99 2021-06-02}}
<lang factor>USING: math.ranges prettyprint random ;
|