Data commit
This commit is contained in:
parent
7387c8f97b
commit
cb5bb5e222
199093 changed files with 3378972 additions and 0 deletions
16
Task/Loops-Break/Jq/loops-break-1.jq
Normal file
16
Task/Loops-Break/Jq/loops-break-1.jq
Normal file
|
|
@ -0,0 +1,16 @@
|
|||
# 15-bit integers generated using the same formula as rand()
|
||||
# from the Microsoft C Runtime.
|
||||
# Input: [ count, state, rand ]
|
||||
def next_rand_Microsoft:
|
||||
.[0] as $count | .[1] as $state
|
||||
| ( (214013 * $state) + 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];
|
||||
|
||||
# Generate random integers from 0 to (n-1):
|
||||
def rand(n): n * (rand_Microsoft(17) / 32768) | trunc;
|
||||
3
Task/Loops-Break/Jq/loops-break-2.jq
Normal file
3
Task/Loops-Break/Jq/loops-break-2.jq
Normal file
|
|
@ -0,0 +1,3 @@
|
|||
def take(s; cond):
|
||||
label $done
|
||||
| foreach s as $n (null; $n; if $n | cond | not then break $done else . end);
|
||||
1
Task/Loops-Break/Jq/loops-break-3.jq
Normal file
1
Task/Loops-Break/Jq/loops-break-3.jq
Normal file
|
|
@ -0,0 +1 @@
|
|||
def count(s): reduce s as $i (0; . + 1);
|
||||
Loading…
Add table
Add a link
Reference in a new issue