Data commit
This commit is contained in:
parent
7387c8f97b
commit
cb5bb5e222
199093 changed files with 3378972 additions and 0 deletions
27
Task/Show-ASCII-table/Jq/show-ascii-table-1.jq
Normal file
27
Task/Show-ASCII-table/Jq/show-ascii-table-1.jq
Normal file
|
|
@ -0,0 +1,27 @@
|
|||
# Pretty printing
|
||||
def lpad($len): tostring | ($len - length) as $l | (" " * $l)[:$l] + .;
|
||||
|
||||
def nwise($n):
|
||||
def n: if length <= $n then . else .[0:$n] , (.[$n:] | n) end;
|
||||
n;
|
||||
|
||||
def table($ncols; $colwidth):
|
||||
nwise($ncols) | map(lpad($colwidth)) | join(" ");
|
||||
|
||||
# transposed table
|
||||
def ttable($rows):
|
||||
[nwise($rows)] | transpose[] | join(" ");
|
||||
|
||||
# Representation of control characters, etc
|
||||
def humanize:
|
||||
def special:
|
||||
{ "0": "NUL", "7": "BEL", "8": "BKS",
|
||||
"9": "TAB", "10": "LF ", "13": "CR ",
|
||||
"27": "ESC", "127": "DEL", "155": "CSI" };
|
||||
|
||||
if . < 32 or . == 127 or . == 155
|
||||
then (special[tostring] // "^" + ([64+.]|implode))
|
||||
elif . > 127 and . < 160 then "\\\(.+72|tostring)"
|
||||
else [.] | implode
|
||||
end
|
||||
| lpad(4) ;
|
||||
9
Task/Show-ASCII-table/Jq/show-ascii-table-2.jq
Normal file
9
Task/Show-ASCII-table/Jq/show-ascii-table-2.jq
Normal file
|
|
@ -0,0 +1,9 @@
|
|||
# produce a flat array
|
||||
def prepare($m;$n):
|
||||
[range($m; $n) | "\(lpad(7)): \(humanize)" ];
|
||||
|
||||
# Row-wise presentation of 32 through 127 in 6 columns
|
||||
prepare(32;128) | table(6; 10)
|
||||
|
||||
# Column-wise with 16 rows would be produced by:
|
||||
# prepare(32;128) | ttable(16)
|
||||
2
Task/Show-ASCII-table/Jq/show-ascii-table-3.jq
Normal file
2
Task/Show-ASCII-table/Jq/show-ascii-table-3.jq
Normal file
|
|
@ -0,0 +1,2 @@
|
|||
# Column-wise representation with 16 rows
|
||||
(prepare(128;256) | ttable(16))
|
||||
Loading…
Add table
Add a link
Reference in a new issue