Integer Compression Tool
-
infoInformation
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ȷytranslates tox × 10 ^ y. For example,2ȷ6 == 2e6 == 2000000.ȷy == 1eyandxȷ == xe3(soȷis a short way of representing1000).⁽starts a two-digit base-250 number literal, where¡represents1andżrepresents250. If the number is greater than31500,62850is subtracted (to allow negative integers to be compressed this way too), and otherwise,750is added. This can represent positive numbers between1001and32250, and negative numbers from-31349to-100(this is because compressing three-digit numbers wouldn't be helpful, and1000can be represented viaȷ). For example,⁽½¥evaluates to3505: Try It Online!“...’denotes a longer base-250 number where¡represents1andżrepresents250(just like with⁽). For example,“ṄBṭ/Ḷ£Þ⁻’evaluates to12345678901234567890: Try It Online!“...‘denotes a code page index list. Here,¡represents0andżrepresents249, and instead of forming a base-250 number, each character translates to one number, and a list of numbers is returned. For example,“Æ⁺©¬‘evaluates to[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.For example,
[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 be780273924267b8¤(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“İṾ³ĠÑ’b8¤.)
eval'd by JavaScript in your browser, so don't input anything that might brick your browser. If you just enter normal integers and integer lists, nothing will go wrong. If the input contains anything other than square brackets, commas, digits, minus signs, or whitespace, evaluation will stop.)