Skip to content

Create a piddle of any dimensions with every element a random integer between MAX and MIN

mohawk2 edited this page Jan 5, 2022 · 2 revisions
   perldl> $a = (( (random( <dim> [, <dim> ..] )) * ( <max> - <min> + 1 )) + <min> )->floor

For example, a 5, 5, 3 piddle with random integers between 1000 and 500

   perldl> $a = (( (random( 5, 5, 3 )) * ( 1000 - 500 + 1 )) + 500 )->floor
   perldl> p $a
   [
    [
     [ 759  780  741  581  828]
     [1000  521  826  706  904]
     [ 583  972  852  812  987]
     [ 680  545  512  620  716]
     [ 588  737  659  641  919]
    ]
    [
     [664 535 829 972 524]
     [970 728 859 775 849]
     [783 511 909 737 952]
     [746 602 817 625 824]
     [557 702 735 529 934]
    ]
    [
     [839 814 908 984 590]
     [518 761 661 877 523]
     [904 728 810 528 820]
     [530 576 850 639 941]
     [831 874 662 965 601]
    ]
   ]
Clone this wiki locally