Topic: APLX Help : Help on APL language : APL Primitives : ? Deal
[ Previous | Next | Contents | Index | APL Home ]

www.microapl.co.uk

? Deal


Two-argument form  See also one-argument form Roll

Generates as many random numbers as are specified in the left-hand argument from the first N numbers starting at ⎕IO, where N is specified in the right-hand argument. Each number generated is unique; that is to say there are no repetitions. The left and right arguments must be simple numeric scalars or one-element vectors.

             10 ? 100                (A request for 10 unique random numbers
       46 54 22 5 68 94 39 52 84 4    in the range 1 to 100, assuming ⎕IO is 1 )
             LIST ← 3 ? 10           (3 random numbers between 1 and 10
                                      are put in LIST)
             BINGO←4 4⍴16?100
             BINGO                   (16 random numbers between 1 and 100
       41 12 46 71                    are put into a 4-by-4 matrix called
        6 54 68  4                    BINGO)
       63 94 87 58
       21 70 50 75
             4 ? 3                   (A request for 4 unique integers in
       DOMAIN ERROR                   the range 1 to 3 causes an error)

Note: The system variable ⎕RL (random link) contains a value used to generate random numbers. To generate the same number(s) on two occasions, set ⎕RL to the same value before each use of ?.

             ⎕RL ← 12345
             5 ? 10000
       97 834 948 36 12
             ⎕RL ← 12345
             5 ? 10000
       97 834 948 36 12

Topic: APLX Help : Help on APL language : APL Primitives : ? Deal
[ Previous | Next | Contents | Index | APL Home ]