routine rand
1 | language documentation Terms |
1.1 | (Terms) term rand |
2 | class Range |
2.1 | (Range) method rand |
3 | class Num |
3.1 | (Num) method rand |
4 | role Real |
4.1 | (Real) routine rand |
5 | class Cool |
5.1 | (Cool) method rand |
Documentation for routine rand
assembled from the following types:
language documentation Terms
From Terms
(Terms) term rand
Returns a pseudo-random Num in the range 0..^1
.
class Range
From Range
(Range) method rand
Defined as:
method rand(Range --> Num)
Returns a pseudo-random value belonging to the range.
say (1^..5).rand; # OUTPUT: «1.02405550417031»say (0.1..0.3).rand; # OUTPUT: «0.2130353370062»
class Num
From Num
(Num) method rand
method rand(Num: --> Num)
Returns a pseudo random number between 0 and the invocant.
role Real
From Real
(Real) routine rand
sub term:<rand> (--> Num)method rand(Real: --> Real)
Returns a pseudo-random number between zero (inclusive) and the number (non-inclusive). The Bridge
method is used to coerce the Real
to a numeric that supports rand method.
The term form returns a pseudo-random Num
between 0e0 (inclusive) and 1e0 (non-inclusive.)
class Cool
From Cool
(Cool) method rand
Defined as:
method rand()
Coerces the invocant to Num and returns a pseudo-random value between zero and the number.
say 1e5.rand; # OUTPUT: «33128.495184283»