3 ms·
I had a go at doing this in Lil, with the simplification of using spaces for alignment instead of tabs, since tab-formatting can be very brittle: on format
by RodgerTheGreat 2y ago
I had a go at doing this in Lil, with the simplification of using spaces for alignment instead of tabs, since tab-formatting can be very brittle:
on format_tab x do
w:max each r in x count @ r end
f:(list "%%-%is ")format -1 drop w
("\n",""fuse f,"%s")format x
end
The basic idea is to assemble a format string which right-pads all but the last column, and then use that format string uniformly across all rows.
And then in K for comparison (somewhat clumsily):
ft:{,/"\n"/((1+|/#:''t)$/:t:-1_'x),'-1#'x}
Much simpler still if we permit trailing whitespace padding:
ft:{,/"\n"/(1+|/#:''x)$/:x}