diff options
| author | Marshall Lochbaum <mwlochbaum@gmail.com> | 2021-05-18 21:51:13 -0400 |
|---|---|---|
| committer | Marshall Lochbaum <mwlochbaum@gmail.com> | 2021-05-18 21:51:13 -0400 |
| commit | eb75383cad78627040337df29dea7e397735ed63 (patch) | |
| tree | 91319d47ed97a87999b583acae1738348c667c80 | |
| parent | 4b3f869bb014710d3f55f9cfc8a5cc3c0ddd2a98 (diff) | |
Full •Repr implementation in f.bqn
| -rw-r--r-- | docs/bqn.js | 10 | ||||
| -rw-r--r-- | md.bqn | 6 | ||||
| -rw-r--r-- | src/f.bqn | 33 |
3 files changed, 30 insertions, 19 deletions
diff --git a/docs/bqn.js b/docs/bqn.js index 86354d54..1e7631f5 100644 --- a/docs/bqn.js +++ b/docs/bqn.js @@ -390,10 +390,10 @@ let bqn = bqngen(compile, rt_sys); // Formatter let fmtnum = x => str(x==Infinity ? "∞" : x==-Infinity ? "¯∞" : (""+x).replace(/-/g,"¯")); -let fmt1 = run( - [15,1,25,21,0,1,22,0,2,22,0,3,22,0,4,22,0,5,4,4,11,14,0,65,0,15,0,18,0,18,19,0,38,0,66,8,3,2,0,41,0,10,0,38,0,55,8,8,21,0,5,3,2,0,41,0,55,0,39,0,8,8,8,0,19,9,22,0,6,11,14,15,2,22,0,7,11,14,0,11,0,8,0,48,19,0,43,15,3,8,22,0,8,11,14,15,4,22,0,9,11,14,15,5,22,0,10,11,14,15,6,15,7,3,2,0,41,15,8,0,47,3,2,0,41,0,10,0,39,0,10,0,38,0,47,8,0,37,0,7,8,8,8,8,22,0,11,11,14,0,75,0,19,0,74,17,15,9,15,10,3,2,0,41,0,10,0,11,0,44,19,0,7,0,11,0,10,0,48,19,19,8,3,2,0,41,0,14,0,14,0,44,0,44,3,2,19,8,22,0,12,11,14,15,11,22,0,13,11,14,15,12,22,0,14,11,14,15,13,15,14,15,15,3,3,0,41,0,28,0,55,7,0,8,0,17,19,0,36,0,33,0,0,7,0,12,0,0,0,8,0,38,0,44,8,19,0,10,19,8,8,22,0,15,11,14,31,0,6,31,0,15,21,0,14,3,2,0,41,0,32,21,0,2,7,0,12,0,53,19,0,17,0,36,0,33,0,7,7,8,9,8,21,0,14,3,3,0,41,0,13,0,3,0,48,19,8,22,0,16,11,14,15,16,22,0,17,11,14,0,16,0,16,21,0,16,9,21,0,17,0,27,0,47,19,0,19,9,3,2,0,41,0,15,0,12,0,53,19,8,21,0,2,19,22,0,18,11,14,21,0,18,0,36,0,30,0,54,0,0,0,55,17,0,39,0,18,8,7,8,0,17,9,0,21,0,45,19,25,0,47,0,31,0,20,7,21,0,1,0,1,16,17,0,24,0,40,0,35,0,29,0,32,0,2,7,7,7,8,16,0,33,0,45,0,46,3,2,0,42,0,0,8,7,21,0,2,17,0,17,16,0,27,0,38,0,45,8,0,40,0,44,8,16,25,21,0,1,0,14,16,0,21,0,45,17,22,0,3,11,0,4,0,47,17,21,1,7,16,22,0,4,11,14,15,17,22,0,5,11,14,21,0,1,0,17,21,0,1,0,14,16,0,20,0,45,17,0,18,31,0,3,0,33,0,2,7,16,17,17,0,20,0,38,0,33,0,0,7,8,31,0,5,3,2,0,41,0,16,0,36,0,10,8,0,8,0,44,19,8,31,0,4,17,25,21,0,1,0,17,16,0,31,0,28,0,56,7,0,17,0,14,0,27,0,45,19,0,39,0,19,8,19,0,18,0,16,19,7,21,0,1,0,14,16,21,1,7,0,47,17,17,0,18,16,25,0,56,0,17,21,0,1,0,10,16,21,0,2,3,2,17,22,0,3,11,14,21,0,3,21,0,1,31,0,3,3,3,0,19,16,0,18,16,25,0,69,0,18,21,0,1,0,26,16,0,21,0,47,17,0,21,0,45,17,17,0,18,0,68,17,0,19,16,25,21,0,1,0,14,16,0,27,0,45,17,22,0,3,11,14,0,70,21,0,2,0,16,0,3,0,47,19,0,29,0,26,7,0,71,19,0,17,9,21,1,5,3,2,0,41,0,8,0,38,0,49,8,8,16,3,2,0,18,16,0,20,21,0,3,17,0,19,16,21,0,1,0,27,0,40,0,72,0,27,0,47,0,1,21,0,2,17,0,3,0,50,17,0,4,0,44,17,17,8,16,0,73,0,20,0,38,0,1,8,31,0,3,17,0,19,16,3,3,0,18,16,25,21,0,1,0,26,16,0,32,0,11,7,0,67,17,0,34,0,1,7,16,0,35,0,0,7,16,0,11,0,48,17,0,33,0,7,7,16,25,21,0,1,0,31,0,76,7,16,21,1,10,0,47,17,21,1,11,0,48,17,0,27,0,38,0,44,0,45,3,2,8,0,40,0,57,8,16,25,21,0,1,0,14,16,0,67,0,31,21,1,5,7,0,31,0,18,0,38,0,77,8,7,9,0,18,9,0,27,0,40,0,58,8,9,3,2,0,41,0,10,0,8,0,47,19,8,16,0,19,16,25,21,0,1,0,31,0,14,7,16,22,0,3,11,14,21,0,3,0,31,0,27,7,0,47,17,0,17,0,28,0,47,7,0,1,0,11,19,0,43,0,34,0,4,7,8,3,2,0,41,0,11,0,8,0,44,19,8,16,22,0,4,11,14,31,0,3,0,31,0,27,7,16,0,11,0,8,0,44,19,0,43,0,47,0,42,0,34,0,4,7,8,8,16,22,0,5,11,14,21,0,1,0,31,0,20,7,0,47,0,20,21,0,4,0,10,16,0,2,21,0,2,17,0,1,16,17,0,6,31,0,4,17,0,2,21,0,2,17,0,32,0,19,7,21,0,5,17,17,0,11,0,1,0,48,19,0,4,0,44,19,0,43,0,19,8,16,0,48,0,42,0,18,0,36,0,8,8,8,16,22,0,6,11,14,31,0,6,21,1,9,0,9,0,36,21,1,8,8,3,2,0,41,31,0,5,0,17,16,0,13,0,38,0,24,0,38,0,47,8,8,16,8,16,21,1,10,0,48,17,25,21,0,1,0,31,21,1,18,7,16,21,1,13,0,47,0,15,21,0,2,17,17,21,1,11,21,0,1,0,11,16,17,25,21,0,1,0,11,16,22,0,3,11,14,0,78,0,16,0,40,21,0,1,8,16,0,21,0,44,17,22,0,1,12,14,21,0,1,0,14,16,0,21,0,45,17,22,0,4,11,0,10,16,0,1,16,0,11,0,38,0,44,8,0,43,0,46,8,16,22,0,5,11,14,0,59,22,0,6,11,14,15,18,22,0,7,11,14,21,0,1,0,25,0,38,0,16,0,11,21,0,6,19,0,0,0,47,19,8,31,0,7,3,2,0,41,0,11,0,10,0,47,19,8,16,22,0,1,12,14,21,0,6,0,20,0,38,0,1,8,21,0,4,17,21,0,5,0,42,0,18,8,21,0,1,17,31,0,5,0,42,0,18,8,0,62,0,20,21,0,4,0,18,0,47,17,0,27,0,45,17,17,0,17,31,0,4,17,0,27,0,40,31,0,6,8,16,17,0,19,16,21,0,3,0,10,0,47,17,0,43,21,1,8,21,1,10,0,47,19,21,1,11,31,0,3,19,8,16,25,21,0,1,21,1,14,21,1,12,3,2,0,41,0,14,0,11,0,44,19,0,33,0,7,7,9,8,16,25,21,0,1,21,1,14,0,45,17,25,0,79,0,80,0,81,0,82,0,83,3,5,0,31,0,15,0,18,0,18,19,7,0,63,17,22,0,3,11,14,0,16,0,16,0,36,21,1,16,0,36,21,0,3,0,27,16,0,26,3,2,0,41,0,10,0,11,0,47,19,8,8,8,0,8,0,37,0,19,8,0,44,19,21,1,17,3,2,0,41,0,15,0,12,0,53,19,8,21,1,2,19,22,0,4,11,14,21,0,1,21,1,3,16,22,0,5,11,0,27,16,22,0,6,11,14,0,64,0,1,0,84,17,0,27,21,0,6,17,22,0,7,11,14,0,86,0,39,0,18,8,0,18,0,85,19,22,0,8,11,14,0,16,0,31,31,0,4,0,39,0,27,0,38,0,47,8,0,15,0,12,21,0,7,0,3,0,48,17,19,0,43,0,16,0,36,31,0,8,8,8,0,27,0,39,0,0,8,19,8,7,0,10,0,36,0,22,8,0,11,0,44,19,0,1,9,0,47,0,9,21,0,7,17,0,43,0,24,8,9,19,0,18,9,22,0,9,11,14,21,0,5,0,21,0,47,17,0,28,21,0,1,7,21,1,4,0,36,0,17,8,9,31,0,3,0,41,0,48,0,1,21,0,2,17,8,31,0,9,3,3,0,41,31,0,6,0,5,16,0,3,0,48,17,8,16,22,0,10,11,14,21,0,10,21,0,7,0,12,0,48,17,0,43,0,28,31,0,5,7,0,27,0,45,19,21,1,2,9,0,9,0,53,19,0,43,0,87,0,39,0,18,8,8,8,16,22,0,10,12,14,31,0,7,31,0,10,3,2,25,21,0,1,0,18,0,38,0,26,0,36,0,31,0,56,7,8,8,16,0,26,21,0,2,0,0,0,47,17,0,18,0,44,17,0,25,16,0,2,0,38,0,8,0,38,0,23,8,8,16,17,25,0,52,0,0,0,55,17,0,8,21,0,1,17,0,2,0,55,0,1,0,61,17,17,0,0,0,51,0,0,0,55,17,0,16,0,1,0,60,19,0,2,0,11,19,21,0,1,17,17,0,0,21,0,1,17,25] - ,[runtime[0],runtime[1],runtime[2],runtime[6],runtime[7],runtime[8],runtime[9],runtime[11],runtime[12],runtime[13],runtime[14],runtime[15],runtime[16],runtime[18],runtime[19],runtime[20],runtime[21],runtime[22],runtime[23],runtime[24],runtime[25],runtime[26],runtime[27],runtime[29],runtime[30],runtime[32],runtime[35],runtime[36],runtime[43],runtime[44],runtime[45],runtime[46],runtime[47],runtime[49],runtime[50],runtime[51],runtime[52],runtime[53],runtime[54],runtime[55],runtime[56],runtime[58],runtime[59],runtime[61],0,-1,Infinity,1,2,5,4,127,32,3,10,'\0',' ','┐','↕','\"','␡','␀','·','*','0',str("@"),str("\'"),str("⟨⟩"),str("⟨"),str("⟩"),str("┌"),str("·─"),str("·╵╎┆┊"),str("┘"),str("┌┐"),str("└┘"),str(" "),str("‿"),str(""),str("array"),str("function"),str("1-modifier"),str("2-modifier"),str("namespace"),str("00321111"),str("("),str(")"),str("{𝔽}")] - ,[[0,1,0,0],[1,1,3,19],[0,0,399,3],[0,0,465,6],[0,0,565,3],[0,0,616,4],[0,0,655,3],[0,0,685,4],[0,0,808,3],[0,0,846,3],[0,0,885,3],[0,0,938,7],[0,0,1168,3],[0,0,1201,8],[0,0,1428,3],[0,0,1457,3],[0,0,1467,11],[0,0,1827,3],[0,0,1879,3]] +let [fmt1,repr] = run( + [15,1,25,31,0,1,22,0,3,22,0,4,22,0,5,22,0,6,4,4,11,14,0,68,0,15,0,18,0,18,19,0,40,0,69,8,3,2,0,43,0,10,0,40,0,58,8,8,21,0,6,3,2,0,43,0,58,0,41,0,8,8,8,22,0,7,11,14,15,2,22,0,8,11,14,0,11,0,8,0,50,19,0,45,15,3,8,22,0,9,11,14,15,4,22,0,10,11,14,15,5,22,0,11,11,14,15,6,15,7,3,2,0,43,15,8,0,49,3,2,0,43,0,10,0,41,0,10,0,40,0,49,8,0,39,0,7,8,8,8,8,22,0,12,11,14,0,78,0,19,0,77,17,15,9,15,10,3,2,0,43,0,10,0,11,0,46,19,0,7,0,11,0,10,0,50,19,19,8,3,2,0,43,0,14,0,14,0,46,0,46,3,2,19,8,22,0,13,11,14,15,11,22,0,14,11,14,15,12,22,0,15,11,14,15,13,15,14,15,15,3,3,0,43,0,30,0,58,7,0,8,0,17,19,0,38,0,35,0,0,7,0,12,0,0,0,8,0,40,0,46,8,19,0,10,19,8,8,22,0,16,11,14,21,0,7,0,19,9,31,0,16,21,0,15,3,2,0,43,0,34,21,0,3,7,0,12,0,55,19,0,17,0,38,0,35,0,7,7,8,9,8,21,0,15,3,3,0,43,0,13,0,3,0,50,19,8,22,0,17,11,14,15,16,22,0,18,11,14,0,86,0,87,0,88,0,89,0,90,3,5,0,33,0,15,0,18,0,18,19,7,0,67,17,22,0,19,11,14,0,50,0,41,0,1,8,0,31,0,28,7,21,0,19,19,21,0,18,21,0,17,0,38,31,0,19,0,28,16,0,27,3,2,0,43,0,10,0,11,0,49,19,8,8,8,0,28,0,49,19,0,19,9,22,0,20,11,14,0,16,0,16,31,0,17,9,31,0,20,3,2,0,43,0,15,0,12,0,55,19,8,21,0,3,19,22,0,21,11,14,15,17,22,0,22,11,14,0,16,0,15,0,18,0,16,0,26,0,11,0,0,0,49,19,19,19,0,18,0,15,19,0,62,19,0,33,21,0,7,0,18,0,80,19,7,0,18,9,0,21,0,49,19,0,33,21,0,22,0,18,0,91,19,7,0,18,9,0,23,0,72,19,0,18,0,71,19,3,3,0,43,0,34,21,0,3,7,0,31,0,27,7,0,50,0,17,0,56,17,0,24,0,50,0,49,0,46,3,3,17,19,0,35,0,4,7,9,8,22,0,23,11,14,0,28,0,38,21,0,22,8,0,18,0,92,19,21,0,23,0,16,31,0,23,0,39,0,18,8,0,14,19,3,3,0,43,0,11,0,3,0,50,19,8,22,0,24,11,14,31,0,7,31,0,24,3,2,0,43,21,0,3,0,11,0,46,19,8,22,0,25,11,14,0,30,0,46,7,0,29,0,93,19,31,0,18,31,0,22,8,0,28,0,49,19,22,0,26,11,14,0,16,0,16,31,0,25,9,31,0,26,3,2,0,43,0,15,0,12,0,55,19,8,21,0,3,19,22,0,27,11,14,21,0,21,0,38,0,32,0,57,0,0,0,58,17,0,41,0,18,8,7,8,0,17,9,0,21,0,47,19,21,0,27,3,2,25,0,49,0,33,0,20,7,31,0,1,0,1,16,17,0,25,0,42,0,37,0,31,0,34,0,2,7,7,7,8,16,0,35,0,47,0,48,3,2,0,44,0,0,8,7,31,0,2,17,0,17,16,0,28,0,40,0,47,8,0,42,0,46,8,16,25,21,0,1,0,14,16,0,21,0,47,17,22,0,3,11,0,4,0,49,17,21,1,8,16,22,0,4,11,14,15,18,22,0,5,11,14,21,0,1,0,17,31,0,1,0,14,16,0,20,0,47,17,0,18,31,0,3,0,35,0,2,7,16,17,17,0,20,0,40,0,35,0,0,7,8,31,0,5,3,2,0,43,0,16,0,38,0,10,8,0,8,0,46,19,8,31,0,4,17,25,21,0,1,0,17,16,0,33,0,30,0,59,7,0,17,0,14,0,28,0,47,19,0,41,0,19,8,19,0,18,0,16,19,7,31,0,1,0,14,16,21,1,8,0,49,17,17,0,18,16,25,0,59,0,17,21,0,1,0,10,16,31,0,2,3,2,17,22,0,3,11,14,21,0,3,31,0,1,31,0,3,3,3,0,19,16,0,18,16,25,0,72,0,18,31,0,1,0,27,16,0,21,0,49,17,0,21,0,47,17,17,0,18,0,71,17,0,19,16,25,21,0,1,0,14,16,0,28,0,47,17,22,0,3,11,14,0,73,21,0,2,0,16,0,3,0,49,19,0,31,0,27,7,0,74,19,0,17,9,21,1,6,3,2,0,43,0,8,0,40,0,51,8,8,16,3,2,0,18,16,0,20,21,0,3,17,0,19,16,31,0,1,0,28,0,42,0,75,0,28,0,49,0,1,31,0,2,17,0,3,0,52,17,0,4,0,46,17,17,8,16,0,76,0,20,0,40,0,1,8,31,0,3,17,0,19,16,3,3,0,18,16,25,31,0,1,0,27,16,0,34,0,11,7,0,70,17,0,36,0,1,7,16,0,37,0,0,7,16,0,11,0,50,17,0,35,0,7,7,16,25,31,0,1,0,33,0,79,7,16,21,1,11,0,49,17,21,1,12,0,50,17,0,28,0,40,0,46,0,47,3,2,8,0,42,0,60,8,16,25,31,0,1,0,14,16,0,70,0,33,21,1,6,7,0,33,0,18,0,40,0,80,8,7,9,0,18,9,0,28,0,42,0,61,8,9,3,2,0,43,0,10,0,8,0,49,19,8,16,0,19,16,25,21,0,1,0,33,0,14,7,16,22,0,3,11,14,21,0,3,0,33,0,28,7,0,49,17,0,17,0,30,0,49,7,0,1,0,11,19,0,45,0,36,0,4,7,8,3,2,0,43,0,11,0,8,0,46,19,8,16,22,0,4,11,14,31,0,3,0,33,0,28,7,16,0,11,0,8,0,46,19,0,45,0,49,0,44,0,36,0,4,7,8,8,16,22,0,5,11,14,31,0,1,0,33,0,20,7,0,49,0,20,21,0,4,0,10,16,0,2,21,0,2,17,0,1,16,17,0,6,31,0,4,17,0,2,31,0,2,17,0,34,0,19,7,21,0,5,17,17,0,11,0,1,0,50,19,0,4,0,46,19,0,45,0,19,8,16,0,50,0,44,0,18,0,38,0,8,8,8,16,22,0,6,11,14,31,0,6,21,1,10,0,9,0,38,21,1,9,8,3,2,0,43,31,0,5,0,17,16,0,13,0,40,0,25,0,40,0,49,8,8,16,8,16,21,1,11,0,50,17,25,21,0,1,0,33,21,1,21,7,16,21,1,14,0,49,0,15,31,0,2,17,17,21,1,12,31,0,1,0,11,16,17,25,21,0,1,0,11,16,22,0,3,11,14,0,81,0,16,0,42,21,0,1,8,16,0,21,0,46,17,22,0,1,12,14,21,0,1,0,14,16,0,21,0,47,17,22,0,4,11,0,10,16,0,1,16,0,11,0,40,0,46,8,0,45,0,48,8,16,22,0,5,11,14,0,62,22,0,6,11,14,15,19,22,0,7,11,14,21,0,1,0,26,0,40,0,16,0,11,21,0,6,19,0,0,0,49,19,8,31,0,7,3,2,0,43,0,11,0,10,0,49,19,8,16,22,0,1,12,14,21,0,6,0,20,0,40,0,1,8,21,0,4,17,21,0,5,0,44,0,18,8,31,0,1,17,31,0,5,0,44,0,18,8,0,65,0,20,21,0,4,0,18,0,49,17,0,28,0,47,17,17,0,17,31,0,4,17,0,28,0,42,31,0,6,8,16,17,0,19,16,21,0,3,0,10,0,49,17,0,45,21,1,9,21,1,11,0,49,19,21,1,12,31,0,3,19,8,16,25,31,0,1,21,1,15,21,1,13,3,2,0,43,0,14,0,11,0,46,19,0,35,0,7,7,9,8,16,25,31,0,1,21,1,15,0,47,17,25,0,16,0,16,31,0,4,9,0,8,0,39,0,19,8,0,46,19,31,0,0,3,2,0,43,0,15,0,12,0,55,19,8,21,1,3,19,22,0,6,11,14,21,0,1,21,1,4,16,22,0,7,11,0,28,16,22,0,8,11,14,0,66,0,1,0,82,17,0,28,21,0,8,17,22,0,9,11,14,0,84,0,41,0,18,8,0,18,0,83,19,22,0,10,11,14,0,16,0,33,31,0,6,0,41,0,28,0,40,0,49,8,0,15,0,12,21,0,9,0,3,0,50,17,19,0,45,0,16,0,38,31,0,10,8,8,0,28,0,41,0,0,8,19,8,7,0,10,0,38,0,22,8,0,11,0,46,19,0,1,9,0,49,0,9,21,0,9,17,0,45,0,25,8,9,19,0,18,9,22,0,11,11,14,21,0,7,0,21,0,49,17,0,30,31,0,1,7,21,1,5,0,38,0,17,8,9,0,16,31,0,5,31,0,2,19,31,0,11,3,3,0,43,31,0,8,0,5,16,0,3,0,50,17,8,16,22,0,12,11,14,21,0,12,21,0,9,0,12,0,50,17,0,45,0,30,31,0,7,7,0,28,0,47,19,21,1,3,9,0,9,0,55,19,0,45,0,85,0,41,0,18,8,8,8,16,22,0,12,12,14,31,0,9,31,0,12,3,2,25,31,0,1,21,1,27,16,25,31,0,1,0,18,0,40,0,27,0,38,0,33,0,59,7,8,8,16,0,27,31,0,2,0,0,0,49,17,0,18,0,46,17,0,26,16,0,2,0,40,0,8,0,40,0,24,8,8,16,17,25,0,54,0,0,0,58,17,0,8,21,0,1,17,0,2,0,58,0,1,0,64,17,17,0,0,0,53,0,0,0,58,17,0,16,0,1,0,63,19,0,2,0,11,19,21,0,1,17,17,0,0,31,0,1,17,25] + ,[runtime[0],runtime[1],runtime[2],runtime[6],runtime[7],runtime[8],runtime[9],runtime[11],runtime[12],runtime[13],runtime[14],runtime[15],runtime[16],runtime[18],runtime[19],runtime[20],runtime[21],runtime[22],runtime[23],runtime[24],runtime[25],runtime[26],runtime[27],runtime[28],runtime[29],runtime[30],runtime[32],runtime[35],runtime[36],runtime[42],runtime[43],runtime[44],runtime[45],runtime[46],runtime[47],runtime[49],runtime[50],runtime[51],runtime[52],runtime[53],runtime[54],runtime[55],runtime[56],runtime[58],runtime[59],runtime[61],0,-1,Infinity,1,2,5,4,127,32,3,7,10,'\0',' ','┐','↕','\"','␡','␀','·','0','*',str("@"),str("\'"),str("⟨⟩"),str("⟨"),str("⟩"),str("┌"),str("·─"),str("·╵╎┆┊"),str("┘"),str("┌┐"),str("└┘"),str(" "),str("‿"),str(""),str("00321111"),str("("),str(")"),str("{𝔽}"),str("array"),str("function"),str("1-modifier"),str("2-modifier"),str("namespace"),str(","),str("<"),str("Can\'t format block")] + ,[[0,1,0,0],[0,0,3,28],[0,0,737,3],[0,0,803,6],[0,0,903,3],[0,0,954,4],[0,0,993,3],[0,0,1023,4],[0,0,1146,3],[0,0,1184,3],[0,0,1223,3],[0,0,1276,7],[0,0,1506,3],[0,0,1539,8],[0,0,1766,3],[0,0,1795,3],[2,0,1805,13],[0,0,2105,3],[0,0,2113,3],[0,0,2165,3]] )(list([type, decompose, glyph, fmtnum])); let fmt = x => unstr(fmt1(x)); @@ -458,7 +458,7 @@ let extendedbqn = (x,w) => { let dynsys = f => { f.dynamic=1; return f; } let sysvals = { bqn:(x,w)=> bqn(req1str("•BQN",x,w)), js:dojs, extendedbqn, - type, glyph, decompose, fmt:fmt1, repr:fmtnum, unixtime, listkeys, + type, glyph, decompose, fmt:fmt1, repr, unixtime, listkeys, listsys: dynsys(() => list(Object.keys(sysvals).sort().map(str))), math: obj2ns(Math,("LN10 LN2 LOG10E LOG2E cbrt expm1 hypot log10 log1p log2 round trunc atan2 cos cosh sin sinh tan tanh").split(" "), f=>typeof f==="function"?runtime[60](f,0):f) }; @@ -621,10 +621,8 @@ GetMultiHighlights ← { ################################ -# Format an array to a character matrix -# Won't work on functions until we can catch errors -fmtm ← •Import "src/f.bqn" -Fmt ← ⟨•Type,•Decompose,•Glyph,•Repr⟩ _fmtm +# Format an array to a string +fmt ← ⊑ (•Import "src/f.bqn"){𝔽} ⟨•Type,•Decompose,•Glyph,•Repr⟩ ################################ @@ -1,7 +1,7 @@ # Format an array to a string including newlines { - ⟨Type,Decomp,FF,FN⟩←𝕗 # Format a number or operation to a string - FmtAtom ← ≍ <⟜@◶⟨@⊸≠◶⟨"@","'"⊸(∾∾⊣)⟩,FN⟩ + ⟨Type,Decomp,FF,FN⟩←𝕩 + ReprAtom ← <⟜@◶⟨@⊸≠◶⟨"@","'"⊸(∾∾⊣)⟩,FN⟩ # Vertical padding for arrays of rank greater than 2 PadCount ← { @@ -77,24 +77,37 @@ } # Format data type - FmtDat ← (2⌊≡)◶⟨FmtAtom,(∨´∘⥊3≤Type⌜)◶FmtSimple‿FmtMixed,FmtMixed⟩ + FmtDat ← (2⌊≡)◶⟨≍ReprAtom,(∨´∘⥊3≤Type⌜)◶FmtSimple‿FmtMixed,FmtMixed⟩ # Format part of a compound operation; return precedence‿string - FmtOp ← { - tn ← '*'(∾∾⊣)¨"array"‿"function"‿"1-modifier"‿"2-modifier"‿"namespace" - FmtComp ← Type (3≤⊣)◶⟨0≍○<(1=≠)◶⟨⊑tn,⊏⟩∘FmtDat∘⊢, FmtOp⟩ ⊢ + _dispOp_ ← { + FmtComp ← Type (3≤⊣)◶⟨0≍○<·𝔽⊢, 𝕊⟩ ⊢ k ← ⊑ d ← Decomp 𝕩 p ← k ⊑ "00321111"-'0' Paren ← "("∾∾⟜")" FromComp ← ∾(⌽⍟(p>1)·-0=↕∘≠)(+⟜⊑Paren∘⊢⍟((2⌊p)≤⊣)1⊸⊑)⟜FmtComp¨⊢ - s ← (2⌊|k)◶⟨⥊∘FF𝕩˙,(𝕨-2)◶tn,FromComp⟩ 1↓d + s ← (2⌊|k)◶⟨⥊∘FF𝕩˙,𝕨𝔾⊢,FromComp⟩ 1↓d s ↩ ∾⟜"{𝔽}"⍟(3>·Type ¯1⊑d˙)⍟(2≤p) s p‿s } + tn ← '*'(∾∾⊣)¨"array"‿"function"‿"1-modifier"‿"2-modifier"‿"namespace" + FmtOp ← ≍1⊑ (1=≠)◶⟨⊑tn,⊏⟩∘FmtDat _dispOp_ (tn⊑˜-⟜2) # Format any value to character matrix - Fmt ← Type (3≤⊣)◶⟨FmtDat⊢,≍1⊑FmtOp⟩ ⊢ + Fmt ← Type (3≤⊣)◶⟨FmtDat⊢,FmtOp⟩ ⊢ - # Convert to string - ¯1↓·⥊ ∾⟜(@+10)˘∘Fmt + # Represent as string + RR ← {Repr𝕩} + ReprList ← (⌈´(2‿1‿0»7⥊2)⊏˜Type⌜)◶⟨ + '"' (⊣∾((1+=)/⊢)∾⊣) ⊢ + 1↓·∾("‿"∾ReprAtom)¨ + "⟨"∾"⟩"«·∾(","∾RR)¨ + ⟩ + ReprArr ← (2⌊=)◶⟨"<"∾RR∘⊑,ReprList,≢∾○ReprList⊢⟩ + ReprDat ← (0=Type)◶⟨ReprAtom,ReprArr⟩ + ReprOp ← 1⊑ RR _dispOp_ ("Can't format block"!0˙) + Repr ← Type (3≤⊣)◶⟨ReprDat⊢,ReprOp⟩ ⊢ + + # Convert Fmt from matrix to string + ⟨¯1↓·⥊ ∾⟜(@+10)˘∘Fmt, Repr⟩ } |
