mirror of
https://github.com/GnoConsortium/gno.git
synced 2024-06-08 05:29:33 +00:00
ddb82cb2e0
Maybe someday I'll become adept at using cvs...
13 lines
270 B
Plaintext
13 lines
270 B
Plaintext
# print k distinct random integers between 1 and n
|
|
|
|
{ random($1, $2) }
|
|
|
|
function random(k, n, A, i, r) {
|
|
for (i = n-k+1; i <= n; i++)
|
|
((r = randint(i)) in A) ? A[i] : A[r]
|
|
for (i in A)
|
|
print i
|
|
}
|
|
|
|
function randint(n) { return int(n*rand())+1 }
|