Data commit

This commit is contained in:
Ingy döt Net 2023-07-01 11:58:00 -04:00
parent 7387c8f97b
commit cb5bb5e222
199093 changed files with 3378972 additions and 0 deletions

View file

@ -0,0 +1,10 @@
for i in range(16):
for j in range(32+i, 127+1, 16):
if j == 32:
k = 'Spc'
elif j == 127:
k = 'Del'
else:
k = chr(j)
print("%3d : %-3s" % (j,k), end="")
print()

View file

@ -0,0 +1,16 @@
from unicodedata import name
from html import escape
def pp(n):
if n <= 32:
return chr(0x2400 + n)
if n == 127:
return ''
return chr(n)
print('<table border="3px" style="background-color:LightCyan;text-align:center">\n <tr>')
for n in range(128):
if n %16 == 0 and 1 < n:
print(" </tr><tr>")
print(f' <td style="center">{n}<br>0x{n:02x}<br><big><b title="{escape(name(pp(n)))}">{escape(pp(n))}</b></big></td>')
print(""" </tr>\n</table>""")

View file

@ -0,0 +1,108 @@
'''Plain text ASCII code table'''
from functools import reduce
from itertools import chain
# asciiTable :: String
def asciiTable():
'''Table of ASCII codes arranged in 16 rows * 6 columns.'''
return unlines(
concat(c.ljust(12, ' ') for c in xs) for xs in (
transpose(chunksOf(16)(
[asciiEntry(n) for n in enumFromTo(32)(127)]
))
)
)
# asciiEntry :: Int -> String
def asciiEntry(n):
'''Number, and name or character, for given point in ASCII code.'''
k = asciiName(n)
return k if '' == k else (
concat([str(n).rjust(3, ' '), ' : ', k])
)
# asciiName :: Int -> String
def asciiName(n):
'''Name or character for given ASCII code.'''
return '' if 32 > n or 127 < n else (
'Spc' if 32 == n else (
'Del' if 127 == n else chr(n)
)
)
# TEST ----------------------------------------------------
# main :: IO ()
def main():
'''Test'''
print(
asciiTable()
)
# GENERIC ABSTRACTIONS ------------------------------------
# chunksOf :: Int -> [a] -> [[a]]
def chunksOf(n):
'''A series of lists of length n,
subdividing the contents of xs.
Where the length of xs is not evenly divible
the final list will be shorter than n.'''
return lambda xs: reduce(
lambda a, i: a + [xs[i:n + i]],
range(0, len(xs), n), []
) if 0 < n else []
# concat :: [[a]] -> [a]
# concat :: [String] -> String
def concat(xxs):
'''The concatenation of all the elements in a list.'''
xs = list(chain.from_iterable(xxs))
unit = '' if isinstance(xs, str) else []
return unit if not xs else (
''.join(xs) if isinstance(xs[0], str) else xs
)
# enumFromTo :: (Int, Int) -> [Int]
def enumFromTo(m):
'''Integer enumeration from m to n.'''
return lambda n: list(range(m, 1 + n))
# splitAt :: Int -> [a] -> ([a], [a])
def splitAt(n):
'''A tuple pairing the prefix of length n
with the rest of xs.'''
return lambda xs: (xs[0:n], xs[n:])
# transpose :: Matrix a -> Matrix a
def transpose(m):
'''The rows and columns of the argument transposed.
(The matrix containers and rows can be lists or tuples).'''
if m:
inner = type(m[0])
z = zip(*m)
return (type(m))(
map(inner, z) if tuple != inner else z
)
else:
return m
# unlines :: [String] -> String
def unlines(xs):
'''A single newline-delimited string derived
from a list of strings.'''
return '\n'.join(xs)
# MAIN ---
if __name__ == '__main__':
main()

View file

@ -0,0 +1,16 @@
# One-liner
# print('\n'.join([''.join(["%3d : %-3s" % (a, 'Spc' if a == 32 else 'Del' if a == 127 else chr(a)) for a in lst]) for lst in [[i+c*16 for c in range(6)] for i in range(32, 47+1)]])
## Detailed version
# List of 16 lists of integers corresponding to
# each row of the table
rows_as_ints = [[i+c*16 for c in range(6)] for i in range(32, 47+1)]
# Function for converting numeric value to string
codepoint2str = lambda codepoint: 'Spc' if codepoint == 32 else 'Del' if codepoint == 127 else chr(codepoint)
rows_as_strings = [["%3d : %-3s" % (a, codepoint2str(a)) for a in row] for row in rows_as_ints]
# Joining columns into rows and printing rows one in a separate line
print('\n'.join([''.join(row) for row in rows_as_strings]))