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ȷy
translates tox × 10 ^ y
. For example,2ȷ6 == 2e6 == 2000000
.ȷy == 1ey
andxȷ == xe3
(soȷ
is a short way of representing1000
).⁽
starts a two-digit base-250 number literal, where¡
represents1
andż
represents250
. If the number is greater than31500
,62850
is subtracted (to allow negative integers to be compressed this way too), and otherwise,750
is added. This can represent positive numbers between1001
and32250
, and negative numbers from-31349
to-100
(this is because compressing three-digit numbers wouldn't be helpful, and1000
can be represented viaȷ
). For example,⁽½¥
evaluates to3505
: Try It Online!“...’
denotes a longer base-250 number where¡
represents1
andż
represents250
(just like with⁽
). For example,“ṄBṭ/Ḷ£Þ⁻’
evaluates to12345678901234567890
: Try It Online!“...‘
denotes a code page index list. Here,¡
represents0
andż
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 -b
converts 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.)