[ prog / sol / mona ]

prog


The Forced Indentation Of Code

64 2022-03-28 11:27

added longest line's length to the >>58 property extractors

>> console.log (((id2code, extractors, formatters, thread, magic) => magic.split (" ").map (id => [id, id2code (thread, id)]).filter (p => p [1] !== null).map (([id, code]) => (text => id.padStart (3, " ") + " " + extractors.map (ex => formatters [ex ["format"]] (ex ["fun"] (text), ex ["fmthow"])).join (" ")) (code.innerText)).join ("\n")) ((thread, id) => document.getElementById ("t" + thread + "p" + id).parentNode.nextElementSibling.querySelector ("code"), [{"fun": s => [...s.matchAll (/\blambda | => /g)].length, "format": "right", "fmthow": {"length": 3, "pad": " "}}, {"fun": (max => s => s.split ("\n").map (s => s.length).reduce ((acc, item) => max (acc, item), 0)) (Math.max), "format": "right", "fmthow": {"length": 5, "pad": " "}}, {"fun": s => (m => m ? m [0] : "?") (s.match (/^(>>> |>> |scheme@\(guile-user\)> )/m)), "format": "id", "fmthow": null}], {"id": (x, how) => x, "right": (x, how) => x.toString ().padStart (how ["length"], how ["pad"])}, 22, "9 10 11 13 14 17 21 24 25 28 30 34 35 37 39 42 43 46 49 53 55 59"))
  9  12   391 >>> 
 10   7   461 scheme@(guile-user)> 
 11  13   483 >> 
 13  15   627 >> 
 14  13   471 >> 
 17  14   524 >>> 
 21  18   789 >>> 
 24  15   851 scheme@(guile-user)> 
 25  13   692 scheme@(guile-user)> 
 28  25  1599 >>> 
 30  10   508 >> 
 34  13   560 >> 
 35  19  1375 scheme@(guile-user)> 
 37  15   642 >> 
 39  21   909 >> 
 42  10   452 >> 
 43  10   444 >> 
 46  18   707 >>> 
 49  23  1070 >>> 
 53  21   873 >>> 
 55  14  1066 scheme@(guile-user)> 
 59  21  1475 scheme@(guile-user)> 
<- undefined
>> 
267


VIP:

do not edit these