[ prog / sol / mona ]

prog


The Forced Indentation Of Code

264 2023-08-03 11:55

Updated lambda and character count table generator code >>76 with split post support

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].every (c => c !== null)).map (([id, code], index) => (text => [index + 1, id].concat (extractors.map (ex => ex ["fun"] (text)))) (code.map (c => c.innerText).join (" "))), repeat (2, "right").concat (extractors.map (ex => ex ["align"])), ["tostring", "id"].concat (extractors.map (ex => ex ["str"])))) ((thread, id) => id.split ('+').map (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 77 81 85 89 90 95 99 100 104 107 109 111 113 115 119 120 121 126 129 132 137 139 149 153 157 176 182 184 189 190 191 192 198 201 203 208 212 214 218 224 229 231 233 236 241 243 245 247 251 256+257 261+262"))
267


VIP:

do not edit these