Data commit
This commit is contained in:
parent
7387c8f97b
commit
cb5bb5e222
199093 changed files with 3378972 additions and 0 deletions
59
Task/Pi/Jq/pi-1.jq
Normal file
59
Task/Pi/Jq/pi-1.jq
Normal file
|
|
@ -0,0 +1,59 @@
|
|||
# The Gibbons spigot, in the mold of the [[#Groovy]] and [[#Python]] programs shown on this page.
|
||||
# The "bigint" functions needed are:
|
||||
# long_minus long_add long_multiply long_div
|
||||
|
||||
def pi_spigot:
|
||||
|
||||
# S is the sixtuple:
|
||||
# q r t k n l
|
||||
# 0 1 2 3 4 5
|
||||
|
||||
def long_lt(x;y): if x == y then false else lessOrEqual(x;y) end;
|
||||
|
||||
def check:
|
||||
long_lt(long_minus(long_add(long_multiply("4"; .[0]); .[1]) ; .[2]);
|
||||
long_multiply(.[4]; .[2]));
|
||||
|
||||
# state: [d, S] where digit is null or a digit ready to be printed
|
||||
def next:
|
||||
.[1] as $S
|
||||
| $S[0] as $q | $S[1] as $r | $S[2] as $t | $S[3] as $k | $S[4] as $n | $S[5] as $l
|
||||
| if $S|check
|
||||
then [$n,
|
||||
[long_multiply("10"; $q),
|
||||
long_multiply("10"; long_minus($r; long_multiply($n;$t))),
|
||||
$t,
|
||||
$k,
|
||||
long_minus( long_div(long_multiply("10";long_add(long_multiply("3"; $q); $r)); $t );
|
||||
long_multiply("10";$n)),
|
||||
$l ]]
|
||||
else [null,
|
||||
[long_multiply($q;$k),
|
||||
long_multiply( long_add(long_multiply("2";$q); $r); $l),
|
||||
long_multiply($t;$l),
|
||||
long_add($k; "1"),
|
||||
long_div( long_add(long_multiply($q; long_add(long_multiply("7";$k); "2")) ; long_multiply($r;$l));
|
||||
long_multiply($t;$l) ),
|
||||
long_add($l; "2") ]]
|
||||
end;
|
||||
|
||||
# Input: input to the filter "nextstate"
|
||||
# Output: [count, space, digit] for successive digits produced by "nextstate"
|
||||
def decorate( nextstate ):
|
||||
|
||||
# For efficiency it is important that the recursive
|
||||
# function have arity 0 and be tail-recursive:
|
||||
def count:
|
||||
.[0] as $count
|
||||
| .[1] as $state
|
||||
| $state[0] as $value
|
||||
| ($state[1] | map(length) | add) as $space
|
||||
| (if $value then [$count, $space, $value] else empty end),
|
||||
( [if $value then $count+1 else $count end, ($state | nextstate)] | count);
|
||||
[0, .] | count;
|
||||
|
||||
# q=1, r=0, t=1, k=1, n=3, l=3
|
||||
[null, ["1", "0", "1", "1", "3", "3"]] | decorate(next)
|
||||
;
|
||||
|
||||
pi_spigot
|
||||
305
Task/Pi/Jq/pi-2.jq
Normal file
305
Task/Pi/Jq/pi-2.jq
Normal file
|
|
@ -0,0 +1,305 @@
|
|||
$ jq -M -n -c -f pi.bigint.jq
|
||||
[0,9,"3"]
|
||||
[1,14,"1"]
|
||||
[2,29,"4"]
|
||||
[3,36,"1"]
|
||||
[4,51,"5"]
|
||||
[5,69,"9"]
|
||||
[6,80,"2"]
|
||||
[7,95,"6"]
|
||||
[8,115,"5"]
|
||||
[9,125,"3"]
|
||||
[10,142,"5"]
|
||||
[11,167,"8"]
|
||||
[12,181,"9"]
|
||||
[13,197,"7"]
|
||||
[14,226,"9"]
|
||||
[15,245,"3"]
|
||||
[16,263,"2"]
|
||||
[17,276,"3"]
|
||||
[18,300,"8"]
|
||||
[19,320,"4"]
|
||||
[20,350,"6"]
|
||||
[21,363,"2"]
|
||||
[22,383,"6"]
|
||||
[23,408,"4"]
|
||||
[24,429,"3"]
|
||||
[25,442,"3"]
|
||||
[26,475,"8"]
|
||||
[27,502,"3"]
|
||||
[28,510,"2"]
|
||||
[29,531,"7"]
|
||||
[30,563,"9"]
|
||||
[31,611,"5"]
|
||||
[32,613,"0"]
|
||||
[33,628,"2"]
|
||||
[34,649,"8"]
|
||||
[35,676,"8"]
|
||||
[36,711,"4"]
|
||||
[37,720,"1"]
|
||||
[38,748,"9"]
|
||||
[39,783,"7"]
|
||||
[40,792,"1"]
|
||||
[41,814,"6"]
|
||||
[42,849,"9"]
|
||||
[43,870,"3"]
|
||||
[44,886,"9"]
|
||||
[45,923,"9"]
|
||||
[46,939,"3"]
|
||||
[47,967,"7"]
|
||||
[48,1004,"5"]
|
||||
[49,1041,"1"]
|
||||
[50,1043,"0"]
|
||||
[51,1059,"5"]
|
||||
[52,1103,"8"]
|
||||
[53,1133,"2"]
|
||||
[54,1135,"0"]
|
||||
[55,1165,"9"]
|
||||
[56,1195,"7"]
|
||||
[57,1212,"4"]
|
||||
[58,1242,"9"]
|
||||
[59,1273,"4"]
|
||||
[60,1297,"4"]
|
||||
[61,1313,"5"]
|
||||
[62,1358,"9"]
|
||||
[63,1375,"2"]
|
||||
[64,1421,"3"]
|
||||
[65,1423,"0"]
|
||||
[66,1447,"7"]
|
||||
[67,1493,"8"]
|
||||
[68,1501,"1"]
|
||||
[69,1533,"6"]
|
||||
[70,1579,"4"]
|
||||
[71,1581,"0"]
|
||||
[72,1613,"6"]
|
||||
[73,1630,"2"]
|
||||
[74,1662,"8"]
|
||||
[75,1701,"6"]
|
||||
[76,1733,"2"]
|
||||
[77,1735,"0"]
|
||||
[78,1781,"8"]
|
||||
[79,1792,"9"]
|
||||
[80,1816,"9"]
|
||||
[81,1849,"8"]
|
||||
[82,1889,"6"]
|
||||
[83,1898,"2"]
|
||||
[84,1961,"8"]
|
||||
[85,1963,"0"]
|
||||
[86,1988,"3"]
|
||||
[87,2013,"4"]
|
||||
[88,2054,"8"]
|
||||
[89,2071,"2"]
|
||||
[90,2104,"5"]
|
||||
[91,2129,"3"]
|
||||
[92,2162,"4"]
|
||||
[93,2195,"2"]
|
||||
[94,2220,"1"]
|
||||
[95,2230,"1"]
|
||||
[96,2287,"7"]
|
||||
[97,2289,"0"]
|
||||
[98,2314,"6"]
|
||||
[99,2340,"7"]
|
||||
[100,2373,"9"]
|
||||
[101,2414,"8"]
|
||||
[102,2448,"2"]
|
||||
[103,2458,"1"]
|
||||
[104,2484,"4"]
|
||||
[105,2534,"8"]
|
||||
[106,2536,"0"]
|
||||
[107,2569,"8"]
|
||||
[108,2602,"6"]
|
||||
[109,2645,"5"]
|
||||
[110,2662,"1"]
|
||||
[111,2696,"3"]
|
||||
[112,2707,"2"]
|
||||
[113,2756,"8"]
|
||||
[114,2775,"2"]
|
||||
[115,2825,"3"]
|
||||
[116,2827,"0"]
|
||||
[117,2853,"6"]
|
||||
[118,2887,"6"]
|
||||
[119,2914,"4"]
|
||||
[120,2964,"7"]
|
||||
[121,2966,"0"]
|
||||
[122,3008,"9"]
|
||||
[123,3027,"3"]
|
||||
[124,3061,"8"]
|
||||
[125,3088,"4"]
|
||||
[126,3114,"4"]
|
||||
[127,3165,"6"]
|
||||
[128,3167,"0"]
|
||||
[129,3202,"9"]
|
||||
[130,3237,"5"]
|
||||
[131,3287,"5"]
|
||||
[132,3289,"0"]
|
||||
[133,3316,"5"]
|
||||
[134,3360,"8"]
|
||||
[135,3387,"2"]
|
||||
[136,3414,"2"]
|
||||
[137,3456,"3"]
|
||||
[138,3466,"1"]
|
||||
[139,3510,"7"]
|
||||
[140,3529,"2"]
|
||||
[141,3564,"5"]
|
||||
[142,3583,"3"]
|
||||
[143,3610,"5"]
|
||||
[144,3653,"9"]
|
||||
[145,3697,"4"]
|
||||
[146,3699,"0"]
|
||||
[147,3752,"8"]
|
||||
[148,3770,"1"]
|
||||
[149,3789,"2"]
|
||||
[150,3825,"8"]
|
||||
[151,3852,"4"]
|
||||
[152,3905,"8"]
|
||||
[153,3933,"1"]
|
||||
[154,3960,"1"]
|
||||
[155,3970,"1"]
|
||||
[156,4006,"7"]
|
||||
[157,4033,"4"]
|
||||
[158,4102,"5"]
|
||||
[159,4104,"0"]
|
||||
[160,4124,"2"]
|
||||
[161,4159,"8"]
|
||||
[162,4203,"4"]
|
||||
[163,4248,"1"]
|
||||
[164,4250,"0"]
|
||||
[165,4269,"2"]
|
||||
[166,4348,"7"]
|
||||
[167,4350,"0"]
|
||||
[168,4361,"1"]
|
||||
[169,4405,"9"]
|
||||
[170,4424,"3"]
|
||||
[171,4460,"8"]
|
||||
[172,4497,"5"]
|
||||
[173,4542,"2"]
|
||||
[174,4569,"1"]
|
||||
[175,4605,"1"]
|
||||
[176,4607,"0"]
|
||||
[177,4644,"5"]
|
||||
[178,4672,"5"]
|
||||
[179,4691,"5"]
|
||||
[180,4727,"9"]
|
||||
[181,4764,"6"]
|
||||
[182,4792,"4"]
|
||||
[183,4820,"4"]
|
||||
[184,4865,"6"]
|
||||
[185,4893,"2"]
|
||||
[186,4913,"2"]
|
||||
[187,4949,"9"]
|
||||
[188,4968,"4"]
|
||||
[189,5005,"8"]
|
||||
[190,5042,"9"]
|
||||
[191,5070,"5"]
|
||||
[192,5098,"4"]
|
||||
[193,5144,"9"]
|
||||
[194,5198,"3"]
|
||||
[195,5200,"0"]
|
||||
[196,5219,"3"]
|
||||
[197,5266,"8"]
|
||||
[198,5276,"1"]
|
||||
[199,5313,"9"]
|
||||
[200,5350,"6"]
|
||||
[201,5387,"4"]
|
||||
[202,5416,"4"]
|
||||
[203,5435,"2"]
|
||||
[204,5471,"8"]
|
||||
[205,5526,"8"]
|
||||
[206,5556,"1"]
|
||||
[207,5558,"0"]
|
||||
[208,5594,"9"]
|
||||
[209,5632,"7"]
|
||||
[210,5660,"5"]
|
||||
[211,5689,"6"]
|
||||
[212,5726,"6"]
|
||||
[213,5746,"5"]
|
||||
[214,5792,"9"]
|
||||
[215,5821,"3"]
|
||||
[216,5849,"3"]
|
||||
[217,5887,"4"]
|
||||
[218,5906,"4"]
|
||||
[219,5961,"6"]
|
||||
[220,5981,"1"]
|
||||
[221,6002,"2"]
|
||||
[222,6038,"8"]
|
||||
[223,6068,"4"]
|
||||
[224,6096,"7"]
|
||||
[225,6134,"5"]
|
||||
[226,6163,"6"]
|
||||
[227,6191,"4"]
|
||||
[228,6238,"8"]
|
||||
[229,6267,"2"]
|
||||
[230,6296,"3"]
|
||||
[231,6316,"3"]
|
||||
[232,6344,"7"]
|
||||
[233,6383,"8"]
|
||||
[234,6411,"6"]
|
||||
[235,6440,"7"]
|
||||
[236,6487,"8"]
|
||||
[237,6525,"3"]
|
||||
[238,6545,"1"]
|
||||
[239,6574,"6"]
|
||||
[240,6621,"5"]
|
||||
[241,6641,"2"]
|
||||
[242,6688,"7"]
|
||||
[243,6717,"1"]
|
||||
[244,6782,"2"]
|
||||
[245,6784,"0"]
|
||||
[246,6795,"1"]
|
||||
[247,6852,"9"]
|
||||
[248,6854,"0"]
|
||||
[249,6910,"9"]
|
||||
[250,6929,"1"]
|
||||
[251,6959,"4"]
|
||||
[252,6988,"5"]
|
||||
[253,7027,"6"]
|
||||
[254,7046,"4"]
|
||||
[255,7085,"8"]
|
||||
[256,7115,"5"]
|
||||
[257,7153,"6"]
|
||||
[258,7181,"6"]
|
||||
[259,7229,"9"]
|
||||
[260,7258,"2"]
|
||||
[261,7288,"3"]
|
||||
[262,7317,"4"]
|
||||
[263,7383,"6"]
|
||||
[264,7385,"0"]
|
||||
[265,7415,"3"]
|
||||
[266,7435,"4"]
|
||||
[267,7474,"8"]
|
||||
[268,7530,"6"]
|
||||
[269,7569,"1"]
|
||||
[270,7571,"0"]
|
||||
[271,7609,"4"]
|
||||
[272,7639,"5"]
|
||||
[273,7678,"4"]
|
||||
[274,7716,"3"]
|
||||
[275,7736,"2"]
|
||||
[276,7766,"6"]
|
||||
[277,7805,"6"]
|
||||
[278,7826,"4"]
|
||||
[279,7873,"8"]
|
||||
[280,7912,"2"]
|
||||
[281,7933,"1"]
|
||||
[282,7971,"3"]
|
||||
[283,7991,"3"]
|
||||
[284,8030,"9"]
|
||||
[285,8060,"3"]
|
||||
[286,8118,"6"]
|
||||
[287,8120,"0"]
|
||||
[288,8168,"7"]
|
||||
[289,8189,"2"]
|
||||
[290,8264,"6"]
|
||||
[291,8266,"0"]
|
||||
[292,8287,"2"]
|
||||
[293,8317,"4"]
|
||||
[294,8374,"9"]
|
||||
[295,8395,"1"]
|
||||
[296,8443,"4"]
|
||||
[297,8464,"1"]
|
||||
[298,8485,"2"]
|
||||
[299,8524,"7"]
|
||||
[300,8544,"3"]
|
||||
[301,8593,"7"]
|
||||
[302,8623,"2"]
|
||||
...
|
||||
Loading…
Add table
Add a link
Reference in a new issue