[ prog / sol / mona ]

prog


The Forced Indentation Of Code

76 2022-04-25 09:55

removed >>66 incipient sorting support on the numeric columns, added autogenerated ranking columns on the lambda and character counts

>> console.log (((repeat, thread, magic) => ((id2code, extractors, formatters, pads, stringify, layout, synthesize, synthspec) => ((table, aligns, strs) => ((table, aligns, strs) => layout (stringify (table, strs, formatters), aligns, pads)) (...synthesize (synthspec, table, aligns, strs))) (magic.split (" ").map (id => [id, id2code (thread, id)]).filter (p => p [1] !== null).map (([id, code], index) => (text => [index + 1, parseInt (id, 10)].concat (extractors.map (ex => ex ["fun"] (text)))) (code.innerText)), repeat (2, "right").concat (extractors.map (ex => ex ["align"])), repeat (2, "tostring").concat (extractors.map (ex => ex ["str"])))) ((thread, id) => document.getElementById ("t" + thread + "p" + id).parentNode.nextElementSibling.querySelector ("code"), [{"fun": s => [...s.matchAll (/\blambda | => /g)].length, "align": "right", "str": "tostring"}, {"fun": (max => s => s.split ("\n").reduce ((acc, item) => max (acc, item.length), 0)) (Math.max), "align": "right", "str": "tostring"}, {"fun": s => (m => m ? m [1] : "?") (s.match (/^(>>>|>>|scheme@\(guile-user\)>) /m)), "align": "left", "str": "id"}], {"id": x => x, "tostring": x => x.toString ()}, {"left": (s, n, pad) => s.padEnd (n, pad), "right": (s, n, pad) => s.padStart (n, pad)}, (rows, how, formatters) => rows.map (r => r.map ((c, index) => formatters [how [index]] (c))), (lengths => (rows, how, pads) => (lengths => rows.map (r => r.map ((c, index) => pads [how [index]] (c, lengths [index], " ")).join (" ")).join ("\n")) (lengths (rows))) ((max => rows => rows.reduce ((acc, r) => acc.map ((a, index) => max (a, r [index].length)), rows [0].map (x => 0))) (Math.max)), ((extend, addcolumns, orderof) => (spec, table, aligns, strs) => [addcolumns (table, spec.map (s => orderof (table, s.column, s.up))), extend (aligns, spec.length, "right"), extend (strs, spec.length, "tostring")]) ((arr, n, item) => arr.concat (repeat (n, item)), (table, columns) => table.map ((r, index) => r.concat (columns.map (c => c [index]))), (table, col, up) => table.map ((r, index) => [r [col], index]).sort (up ? ((a, b) => a [0] - b [0]) : ((a, b) => b [0] - a [0])).map (([val, pos], index) => [pos, index]).sort ((a, b) => a [0] - b [0]).map (a => 1 + a [1])), [{"column": 2, "up": false}, {"column": 3, "up": false}])) ((n, item) => Array.from ({length: n}, (dis, k) => item), 22, "9 10 11 13 14 17 21 24 25 28 30 34 35 37 39 42 43 46 49 53 55 59 65 67 69 70 72"))
 1  9 12  391 >>>                  22 27
 2 10  7  461 scheme@(guile-user)> 27 23
 3 11 13  483 >>                   18 21
 4 13 15  627 >>                   13 17
 5 14 13  471 >>                   19 22
 6 17 14  524 >>>                  16 19
 7 21 18  789 >>>                  11 13
 8 24 15  851 scheme@(guile-user)> 14 12
 9 25 13  692 scheme@(guile-user)> 20 15
10 28 25 1599 >>>                   1  3
11 30 10  508 >>                   23 20
12 34 13  560 >>                   21 18
13 35 19 1375 scheme@(guile-user)>  9  5
14 37 15  642 >>                   15 16
15 39 21  909 >>                    5 10
16 42 10  452 >>                   24 25
17 43 10  444 >>                   25 26
18 46 18  707 >>>                  12 14
19 49 23 1070 >>>                   4  8
20 53 21  873 >>>                   6 11
21 55 14 1066 scheme@(guile-user)> 17  9
22 59 21 1475 scheme@(guile-user)>  7  4
23 65 19 1110 scheme@(guile-user)> 10  7
24 67 25 1716 >>>                   2  2
25 69 10  460 >>                   26 24
26 70 20 1333 scheme@(guile-user)>  8  6
27 72 25 1717 scheme@(guile-user)>  3  1
<- undefined
>> 
267


VIP:

do not edit these