Jump to navigation Jump to search


186 bytes added, 19:52, 29 October 2019
no edit summary
{{Primitive|?|Roll}} is a [[monadic]] [[scalar function]] which returns random or pseudo-random numbers. Each [[scalar]] in the argument must be a non-negative positive integer. If it is a positive number , <source lang=apl inline>n</source>, then and Roll chooses one of the first <source lang=apl inline>n</source> [[Index|indices]]. In some Some dialects allow <source lang=apl inline>n</source> to be zero, in which case Roll chooses a floating-point number between 0 and 1 when the argument has a zero.
== Examples ==
== Description ==
Each [[scalar]] in the argument to Roll must be a non-negative positive integer.
The result of Roll on each number <source lang=apl inline>n</source> is either
* A real number chosen uniformly at random from between 0 and 1, if n is 0; or* One of the elements of <source lang=apl inline>⍳n</source> chosen uniformly at random; or* A real number between 0 and 1 chosen uniformly at random, otherwiseif <source lang=apl inline>n</source> is 0 and the dialect has this extension.
Because [[Iota]] depends on [[index origin]], Roll depends on index origin unless every number in the argument is 0.
=== Lessons ===
* [ APL Cultivation] * [ Jupyter Notebook]
=== Documentation ===
* [ Dyalog]
* [ APLX]
J * [ J Dictionary], [ J NuVoc]

Navigation menu