Data commit
This commit is contained in:
parent
7387c8f97b
commit
cb5bb5e222
199093 changed files with 3378972 additions and 0 deletions
6
Task/Show-ASCII-table/Julia/show-ascii-table-1.julia
Normal file
6
Task/Show-ASCII-table/Julia/show-ascii-table-1.julia
Normal file
|
|
@ -0,0 +1,6 @@
|
|||
for i in 32:127
|
||||
c= i== 0 ? "NUL" : i== 7 ? "BEL" : i== 8 ? "BKS" : i== 9 ? "TAB" :
|
||||
i==10 ? "LF " : i==13 ? "CR " : i==27 ? "ESC" : i==155 ? "CSI" : "|$(Char(i))|"
|
||||
print("$(lpad(i,3)) $(string(i,base=16,pad=2)) $c")
|
||||
(i&7)==7 ? println() : print(" ")
|
||||
end
|
||||
6
Task/Show-ASCII-table/Julia/show-ascii-table-2.julia
Normal file
6
Task/Show-ASCII-table/Julia/show-ascii-table-2.julia
Normal file
|
|
@ -0,0 +1,6 @@
|
|||
for i in 0:255
|
||||
c= i== 0 ? "NUL" : i== 7 ? "BEL" : i== 8 ? "BKS" : i== 9 ? "TAB" :
|
||||
i==10 ? "LF " : i==13 ? "CR " : i==27 ? "ESC" : i==155 ? "CSI" : "|$(Char(i))|"
|
||||
print("$(lpad(i,3)) $(string(i,base=16,pad=2)) $c")
|
||||
(i&7)==7 ? println() : print(" ")
|
||||
end
|
||||
25
Task/Show-ASCII-table/Julia/show-ascii-table-3.julia
Normal file
25
Task/Show-ASCII-table/Julia/show-ascii-table-3.julia
Normal file
|
|
@ -0,0 +1,25 @@
|
|||
print("\e[2J") # clear screen
|
||||
print("""
|
||||
0 1 2 3 4 5 6 7 8 9 A B C D E F
|
||||
╔═══╤═══╤═══╤═══╤═══╤═══╤═══╤═══╤═══╤═══╤═══╤═══╤═══╤═══╤═══╤═══╗
|
||||
║nul│soh│stx│etx│eot│enq│ack│bel│ bs│tab│ lf│ vt│ ff│ cr│ so│ si║
|
||||
""") # indent is set by this (least indented) line
|
||||
for i = 0:14
|
||||
a = string(i,base=16)
|
||||
println( "$a ║ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ ║ $a")
|
||||
println( " ╟───┼───┼───┼───┼───┼───┼───┼───┼───┼───┼───┼───┼───┼───┼───┼───╢")
|
||||
println(i==0 ? " ║dle│dc1│dc2│dc3│dc4│nak│syn│etb│can│ em│eof│esc│ fs│ gs│ rs│ us║"
|
||||
: " ║ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ ║")
|
||||
end
|
||||
println("""
|
||||
f ║ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ ║ f
|
||||
╚═══╧═══╧═══╧═══╧═══╧═══╧═══╧═══╧═══╧═══╧═══╧═══╧═══╧═══╧═══╧═══╝
|
||||
0 1 2 3 4 5 6 7 8 9 A B C D E F
|
||||
""") # """ string is indented here
|
||||
for i = 1:255
|
||||
r,c = divrem(i,16)
|
||||
r,c = 3r+4,4c+5
|
||||
i > 31 && print("\e[$(r-1);$(c-1)H$(lpad(i,3))")
|
||||
6<i<11 || i==155 || i==173 || print("\e[$r;$(c)H$(Char(i))")
|
||||
end
|
||||
print("\e[54;1H")
|
||||
48
Task/Show-ASCII-table/Julia/show-ascii-table-4.julia
Normal file
48
Task/Show-ASCII-table/Julia/show-ascii-table-4.julia
Normal file
|
|
@ -0,0 +1,48 @@
|
|||
#= CONSOLE TABLES =============================================================
|
||||
rn: nrows, rh: height of rows
|
||||
cn: ncols, cw: width of columns
|
||||
T[rn,cn,rh] table data strings
|
||||
cr: rows in colum headers
|
||||
CH[cn,cr] column header strings of max cw length
|
||||
hl: lengths of row header strings
|
||||
RH[rn,rh] row header strings of max length hl
|
||||
==============================================================================#
|
||||
|
||||
struct Table
|
||||
rn::Int; rh::Int; cn::Int; cw::Int; T::Array{String,3}
|
||||
cr::Int; CH::Array{String,2}
|
||||
hl::Int; RH::Array{String,2}
|
||||
function Table(rn,rh,cn,cw,cr,hl) # constructor
|
||||
new(rn,rh,cn,cw,fill("",(rn,cn,rh)), # arrays initialized with empty strings
|
||||
cr,fill("",(cr,cn)), hl,fill("",(rn,rh)))
|
||||
end
|
||||
end
|
||||
Base.iterate(T::Table,i=1) = i<=nfields(T) ? (getfield(T,i),i+1) : nothing
|
||||
|
||||
cpad(s::String,n::Integer) = (m=length(s))<n ? lpad(rpad(s,(n+m)>>1),n) : first(s,n)
|
||||
|
||||
function prt((rn,rh,cn,cw,T, cr,CH, hl,RH)::Table)
|
||||
TL,TX,TR,BH = '╔','╤','╗','═'
|
||||
IL,IX,IR,IV,IH='╟','┼','╢','│','─'
|
||||
BL,BX,BR,BV = '╚','╧','╝','║'
|
||||
|
||||
u,v,w,d,t = BH^cw, IH^cw, " "^hl, cn-2, " "^hl
|
||||
b = w*(cn==1 ? IL*v*IR : IL*v*(IX*v)^d*IX*v*IR)*'\n' # internal separator
|
||||
for r = 1:cr
|
||||
for c = 1:cn t*=cpad(CH[r,c],cw+1) end
|
||||
t *= "\n$w"
|
||||
end
|
||||
|
||||
t *= (cn==1 ? TL*u*TR : TL*u*(TX*u)^d*TX*u*TR)*'\n' # top border
|
||||
for r = 1:rn
|
||||
for p = 1:rh
|
||||
s = cpad(RH[r,p],hl)*BV
|
||||
for c = 1:cn-1
|
||||
s *= cpad(T[r,c,p],cw) * IV
|
||||
end
|
||||
t*= s * cpad(T[r,cn,p],cw) * BV *'\n'
|
||||
end
|
||||
t*=r<rn ? b : cn<2 ? w*BL*u*BR : w*BL*u*(BX*u)^d*BX*u*BR # bottom border
|
||||
end
|
||||
println("\n$t\n")
|
||||
end
|
||||
7
Task/Show-ASCII-table/Julia/show-ascii-table-5.julia
Normal file
7
Task/Show-ASCII-table/Julia/show-ascii-table-5.julia
Normal file
|
|
@ -0,0 +1,7 @@
|
|||
Tbl = Table(16,2,16,3, 2,3) # construct table
|
||||
Tbl.CH[1,:] = string.(0:15,base=16) # Column headers
|
||||
Tbl.RH[:,2] = string.(0:15,base=16) # Row headers
|
||||
for i = 0:255 # populate table, exclude special characters
|
||||
Tbl.T[i>>4+1,i&15+1,1:2]=["$i",i∈(0,7,8,9,10,13,27,155) ? "" : "$(Char(i))"]
|
||||
end
|
||||
prt(Tbl) # format and print table on console
|
||||
Loading…
Add table
Add a link
Reference in a new issue