Random: Difference between revisions
Content added Content deleted
(add random page) |
(elaborate on random overloads) |
||
Line 1: | Line 1: | ||
{{primitive|a?b}} |
{{primitive|a?b<br>a?y}} |
||
'''Random''' takes two |
'''Random''' takes two values and returns random values based on their types. |
||
When given two integers, generates <code>a</code> random integers in the range <code>!b</code>. |
|||
<pre> |
<pre> |
||
6?5 |
6?5 |
||
Line 9: | Line 10: | ||
6?5 |
6?5 |
||
0 2 4 1 4 0 |
0 2 4 1 4 0 |
||
</pre> |
|||
When the right argument is an array, makes <code>a</code> random choices from array <code>y</code>. |
|||
If <code>a</code> is negative, deals <code>[[abs]] a</code> elements from the array without replacement(no repeats of previously chosen elements). |
|||
<pre> |
|||
10?"ABCDE" |
|||
"ABBCDCACEB" |
|||
10?"ABCDE" |
|||
"EABABDACEA" |
|||
-3?"ABCDE" |
|||
"DAE" |
|||
-3?"ABCDE" |
|||
"DCE" |
|||
</pre> |
</pre> |
Revision as of 05:24, 21 July 2021
Random
a?b
a?y
a?y
Random takes two values and returns random values based on their types.
When given two integers, generates a
random integers in the range !b
.
6?5 0 1 1 2 3 2 6?5 0 2 4 1 4 0
When the right argument is an array, makes a
random choices from array y
.
If a
is negative, deals abs a
elements from the array without replacement(no repeats of previously chosen elements).
10?"ABCDE" "ABBCDCACEB" 10?"ABCDE" "EABABDACEA" -3?"ABCDE" "DAE" -3?"ABCDE" "DCE"