Integer Compression Tool
Jelly has four literal types that can represent integers or integer lists shorter than the trivial representation.
ȷallows multiples of powers of ten to be represented in fewer bytes:
x × 10 ^ y. For example,
2ȷ6 == 2e6 == 2000000.
ȷy == 1eyand
xȷ == xe3(so
ȷis a short way of representing
⁽starts a two-digit base-250 number literal, where
250. If the number is greater than
62850is subtracted (to allow negative integers to be compressed this way too), and otherwise,
750is added. This can represent positive numbers between
32250, and negative numbers from
-100(this is because compressing three-digit numbers wouldn't be helpful, and
1000can be represented via
ȷ). For example,
3505: Try It Online!
“...’denotes a longer base-250 number where
250(just like with
⁽). For example,
12345678901234567890: Try It Online!
“...‘denotes a code page index list. Here,
249, and instead of forming a base-250 number, each character translates to one number, and a list of numbers is returned. For example,
[13, 138, 6, 7]: Try It Online!
This utility attempts to compress an integer or list of integers into a literal. Note that often, you can find a shorter way (e.g.
[0, 1]is a digraph nilad,
Ø., which cannot be used in a literal, but can represent that pair itself shorter than any literal could), but this tool is intended for compressing larger values that don't have intelligent algorithmic representations. For example, you can compress a long list of small integers using base conversion -
bconverts its left argument into digits with base based on its right argument, and
ḅdoes the inverse.
[1, 3, 2, 6, 5, 3, 7, 4, 6, 3, 4, 2, 5, 3]can be represented using a codepage index list as
“¢¤£©¦¤¬¥©¤¥£¦¤‘, but in base 8, it can be
780273924267b8¤(which is one byte shorter even with the
¤to make it a single niladic link): Try It Online! (Also, you can compress the number itself to get