Data commit
This commit is contained in:
parent
7387c8f97b
commit
cb5bb5e222
199093 changed files with 3378972 additions and 0 deletions
4
Task/Repeat/Jq/repeat-1.jq
Normal file
4
Task/Repeat/Jq/repeat-1.jq
Normal file
|
|
@ -0,0 +1,4 @@
|
|||
def unoptimized_repeat(f; n):
|
||||
if n <= 0 then empty
|
||||
else f, repeat(f; n-1)
|
||||
end;
|
||||
5
Task/Repeat/Jq/repeat-2.jq
Normal file
5
Task/Repeat/Jq/repeat-2.jq
Normal file
|
|
@ -0,0 +1,5 @@
|
|||
def repeat(f; n):
|
||||
# state: [count, in]
|
||||
def r:
|
||||
if .[0] >= n then empty else (.[1] | f), (.[0] += 1 | r) end;
|
||||
[0, .] | r;
|
||||
9
Task/Repeat/Jq/repeat-3.jq
Normal file
9
Task/Repeat/Jq/repeat-3.jq
Normal file
|
|
@ -0,0 +1,9 @@
|
|||
# If n is a non-negative integer,
|
||||
# then emit a stream of (n + 1) terms: ., f, f|f, f|f|f, ...
|
||||
def repeatedly(f; n):
|
||||
# state: [count, in]
|
||||
def r:
|
||||
if .[0] < 0 then empty
|
||||
else .[1], ([.[0] - 1, (.[1] | f)] | r)
|
||||
end;
|
||||
[n, .] | r;
|
||||
1
Task/Repeat/Jq/repeat-4.jq
Normal file
1
Task/Repeat/Jq/repeat-4.jq
Normal file
|
|
@ -0,0 +1 @@
|
|||
0 | [ repeat(.+1; 3) ]
|
||||
1
Task/Repeat/Jq/repeat-5.jq
Normal file
1
Task/Repeat/Jq/repeat-5.jq
Normal file
|
|
@ -0,0 +1 @@
|
|||
0 | repeatedly(.+1; 3)
|
||||
Loading…
Add table
Add a link
Reference in a new issue