Data commit

This commit is contained in:
Ingy döt Net 2023-07-01 11:58:00 -04:00
parent 7387c8f97b
commit cb5bb5e222
199093 changed files with 3378972 additions and 0 deletions

View file

@ -0,0 +1,4 @@
def unoptimized_repeat(f; n):
if n <= 0 then empty
else f, repeat(f; n-1)
end;

View 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;

View 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;

View file

@ -0,0 +1 @@
0 | [ repeat(.+1; 3) ]

View file

@ -0,0 +1 @@
0 | repeatedly(.+1; 3)