Skip to main content
added 3 characters in body
Source Link
sinedcm
  • 420
  • 3
  • 5

Q (19 characters)

f:{(neg x)?y+til z}

Then use f[-x;y;z]f[x;y;z] as [count of numbers in output set;starting point;size of range]

e.g. f[-5;10;10]f[5;10;10] will output 5 distinct random numbers between 10 and 19 inclusive.

q)\ts do[100000;f[-100;1;10000]]do[100000;f[100;1;10000]]
2418 131456j

Results above show performance at 100,000 iterations of picking 100 random numbers between 1 & 10,000.

Q

f:{x?y+til z}

Then use f[-x;y;z] as [count of numbers in output set;starting point;size of range]

e.g. f[-5;10;10] will output 5 distinct random numbers between 10 and 19 inclusive.

q)\ts do[100000;f[-100;1;10000]]
2418 131456j

Results above show performance at 100,000 iterations of picking 100 random numbers between 1 & 10,000.

Q (19 characters)

f:{(neg x)?y+til z}

Then use f[x;y;z] as [count of numbers in output set;starting point;size of range]

e.g. f[5;10;10] will output 5 distinct random numbers between 10 and 19 inclusive.

q)\ts do[100000;f[100;1;10000]]
2418 131456j

Results above show performance at 100,000 iterations of picking 100 random numbers between 1 & 10,000.

Source Link
sinedcm
  • 420
  • 3
  • 5

Q

f:{x?y+til z}

Then use f[-x;y;z] as [count of numbers in output set;starting point;size of range]

e.g. f[-5;10;10] will output 5 distinct random numbers between 10 and 19 inclusive.

q)\ts do[100000;f[-100;1;10000]]
2418 131456j

Results above show performance at 100,000 iterations of picking 100 random numbers between 1 & 10,000.