-
Notifications
You must be signed in to change notification settings - Fork 1
Encoding
Thomas Kwa edited this page Jan 31, 2019
·
1 revision
Sledgehammer uses Braille as a code page. Unlike the Braille Unicode block or the Braille esolang, Sledgehammer encodes bits within a byte in the following order (e.g. 42 -> ⠬
):
128 8
64 4
32 2
16 1
Full Sledgehammer code page:
⠀⢀⠠⢠⠐⢐⠰⢰⠈⢈⠨⢨⠘⢘⠸⢸⡀⣀⡠⣠⡐⣐⡰⣰⡈⣈⡨⣨⡘⣘⡸⣸⠄⢄⠤⢤⠔⢔⠴⢴⠌⢌⠬⢬⠜⢜⠼⢼⡄⣄⡤⣤⡔⣔⡴⣴⡌⣌⡬⣬⡜⣜⡼⣼⠂⢂⠢⢢⠒⢒⠲⢲⠊⢊⠪⢪⠚⢚⠺⢺⡂⣂⡢⣢⡒⣒⡲⣲⡊⣊⡪⣪⡚⣚⡺⣺⠆⢆⠦⢦⠖⢖⠶⢶⠎⢎⠮⢮⠞⢞⠾⢾⡆⣆⡦⣦⡖⣖⡶⣶⡎⣎⡮⣮⡞⣞⡾⣾⠁⢁⠡⢡⠑⢑⠱⢱⠉⢉⠩⢩⠙⢙⠹⢹⡁⣁⡡⣡⡑⣑⡱⣱⡉⣉⡩⣩⡙⣙⡹⣹⠅⢅⠥⢥⠕⢕⠵⢵⠍⢍⠭⢭⠝⢝⠽⢽⡅⣅⡥⣥⡕⣕⡵⣵⡍⣍⡭⣭⡝⣝⡽⣽⠃⢃⠣⢣⠓⢓⠳⢳⠋⢋⠫⢫⠛⢛⠻⢻⡃⣃⡣⣣⡓⣓⡳⣳⡋⣋⡫⣫⡛⣛⡻⣻⠇⢇⠧⢧⠗⢗⠷⢷⠏⢏⠯⢯⠟⢟⠿⢿⡇⣇⡧⣧⡗⣗⡷⣷⡏⣏⡯⣯⡟⣟⡿⣿
To compress a function (Wolfram Language anonymous function), the Wolfram Language code is first converted to postfix form. Based on token frequencies estimated from WolframLanguageData, the tokens are then Huffman encoded such that no token maps to a list of all 1s. Trailing 1s are removed. The resulting list of bits is the compressed code. If storing in a file, trailing 1s are added to pad to a whole number of bytes. Decompression is the reverse process, with some implicit tokens being inferred.