Initial data commit
This commit is contained in:
parent
72d218235f
commit
f23f22d71c
199087 changed files with 3378941 additions and 0 deletions
17
Task/Loops-Nested/Jq/loops-nested-4.jq
Normal file
17
Task/Loops-Nested/Jq/loops-nested-4.jq
Normal file
|
|
@ -0,0 +1,17 @@
|
|||
# LCG::Microsoft generates 15-bit integers using the same formula
|
||||
# as rand() from the Microsoft C Runtime.
|
||||
# Input: [ count, state, random ]
|
||||
def next_rand_Microsoft:
|
||||
.[0] as $count
|
||||
| ((214013 * .[1]) + 2531011) % 2147483648 # mod 2^31
|
||||
| [$count+1 , ., (. / 65536 | floor) ];
|
||||
|
||||
def rand_Microsoft(seed):
|
||||
[0,seed]
|
||||
| next_rand_Microsoft # the seed is not so random
|
||||
| recurse( next_rand_Microsoft )
|
||||
| .[2];
|
||||
|
||||
# A random integer in [0 ... (n-1)]:
|
||||
# rand_Microsoft returns an integer in 0 .. 32767
|
||||
def rand(n): n * (rand_Microsoft($seed|tonumber) / 32768) | trunc;
|
||||
Loading…
Add table
Add a link
Reference in a new issue