Since it wasn't part of the Wiki on 05AB1E's GitHub pages (I think it should), I'm just gonna add it here now that I better understand it myself.
#How to use the dictionary?
05AB1E has the following dictionary.py file containing all the words it knows. But how do we access the words in this dictionary? Let's take the word "testing" as example:
"testing" can be found on row 1451 of the dictionary file. Since the line-numbers are 1-indexed, and we need the 0-indexed word, we subtract 1.
So, now we have the index (1450), but how to use it?
We open and start a compressed string with "†. We then look at the second column of the info.txt file. (So € is 00; ‚ is 01; etc.)
In the case of "testing" this means î (14) and » (50).
The compressed String for "testing" is therefore: "î»" Try it online. As with almost all 05AB1E pieces of code, the trailing " is optional if you don't access the string, so without works as well in this case.
Some things to note:
All characters that doesn't have any index in the info.txt file can be used as is. This can be useful for adding an s to output a plural instead of singular word or use punctuation like ,.?! for example.
ÿ (string-interpolation) can also be used when you want to insert values from the stack within the string.
† There are different types of compressed strings you can use:
': Take a single compressed word as is (no trailing'required) -'î»: "testing"„: Takes two compressed words with space delimiter (no trailing„required) -„î»î»: "testing testing"...: Takes three compressed words with space delimiter (no trailing...required) -...î»î»î»: "testing testing testing"": Take the compressed string with space delimiter -"î»î»": "testing testing"’: Take the compressed string as is without implicit spaces -’î»î»’: "testingtesting"": Take the compressed string in title-case -"î»î»": "Testing Testing"‘: Take the compressed string in full uppercase -‘î»î»‘: "TESTING TESTING"
Here an example where I use ...ŸTM‚ï! for the string "hello world!" and ’‚¿Þ¡ ÿ ‚ï!’ for the string "goodbye ÿ world!" (note how the spaces and exclamation mark are used as is, because they don't have indices in the info.txt file. In addition, it uses ÿ to insert the "cruel" that was at the top of the stack, which unfortunately wasn't part of the dictionary (but was still compressed using the method at the section below).
#How to compress strings not part of the dictionary?
Although the dictionary.py file is pretty big, it can happen that you need a word which isn't part of it, or a string which is just plain gibberish. So is there a way to compress those as well?
There certainly is, by using .•, which is a compressed base-255 alphabet based string.
Here is a useful program to convert a word/string to the compressed base-255 alphabet based string:
SAsk> 27β 255B ".•ÿ•".
What this program above does is:
SAsk>: Take the 1-indexed alphabet indices of the individual letters of the input27β: Convert these indices from base 27 to a single number255B: Convert this number to Base-255 using 05AB1E's own code page".•ÿ•": Places a leading.•and trailing•before this compressed string
Here an example answer where @Kaldo uses .•zíΘ• to compress the word "goose".
#How to compress large integers?
Let's say we want to use a very big number for something, but it can't really be retrieved by pow-calculations. For example, let's say we want to access the large integer 18238098189071058293 for whatever reason.
In this case we can use both a leading and trailing • to compress a number in the format [1-9][0-9]+.
The example number above will become •15Y1Ò'Θpc•. Try it online. Again, just like with the compressed dictionary string, the trailing • can optionally be removed.
How is this 15Y1Ò'Θpc created? Very simple, the number is converted to Base-255 using 05AB1E's own codepage. So you can use the following program to get a compressed number:
255B "•ÿ•"
Here an example answer where @Emigna uses •3Èñ• for the integer 246060.
#How to compress integer lists?
Sometimes you want to compress an entire list of integers instead of a single number. For example, let's say we want the list [5,93,17,83,4,44,32,19,4,45,83,90,0,14,3,17,17,81] for whatever reason. In this case, we can use the following instead: •4βŸ{©£MG]q‡dZΘp•94в Try it online.
Here a useful program to generate both this compressed number and the Base we want to convert to:
Z>© β 255B ®s"•ÿ•ÿв"
What this program above does is:
Z>: Get the max number + 1 of the input-list (©: and store it in the register)β: Convert the input list from basemax+1to a single number255B: Compress this single number (as we did at the section above)®s"•ÿ•ÿв": Returns the result in the format: leading•, compressed number,•, max+1, trailingв
Here an example answer where I use •4Œ"dóŒfÝŸĀTUÕáOyÖOÀÁàu1⁄4616Žr‡_›y3eß2©ǝ2ƶ"SAÎAñ'¡û†Ø(•91в to compress the list [85,30,29,39,28,37,33,88,31,40,34,89,35,41,32,90,36,38,42,43,44,60,45,61,46,62,47,63,48,64,49,65,81,50,66,51,67,52,68,53,69,86,54,70,87,55,71,56,72,82,57,73,79,80,58,74,59,75,76,77,78,83,84]. (PS: In this answer •6j|eDEJÞó(ÍêΓλùÄÞKüzHÇ-ø`JδŠ2+Öηôî®À8†6/ðÎ6ùøΓ°ÓĆ;ˆ©Ā•2ô is an equal-bytes (57) alternative, since all numbers have exactly two digits.)
- 136.2k
- 14
- 154
- 394