DEV Community

Discussion on: How do you do random?

Collapse
 
rrampage profile image
Raunak Ramakrishnan • Edited

APL:

⍝ `? n` generates random number between 1 and n, both inclusive
(? 10) -1
⍝ If we need more than 1 number, use `⍴` function like:
(? 4⍴ 10) -1
⍝ In above code, x⍴y gives you an array of y's of length x

I am a beginner in this language but it is fascinating at how succinct and elegant some constructs are.