State to Function λ
State to Function λ

State to Function λ

Second iteration of State to Function, the POC to store simple math in a url. Cleaner UI without antd, and the state is now packed with densing instead of url-safe-bitpacking.

Inputs and methods are put together on the Definitions page, either by clicking terms together or by typing them as formulas, with autocomplete. The Applet turns the definition into a small calculator, which can be exported as CSV or as a PDF with a QR code.

Links from the first version still work. They are recognised by their version byte, decoded with url-safe-bitpacking and rewritten in the new format. Still no backend used at all!

Logo rendered with SVG SDF © J.W.↗
Logo rendered with SVG SDF © J.W.
Definitions↗
Definitions
Applet↗
Applet
Methods typed as formulas↗
Methods typed as formulas
Formula autocomplete↗
Formula autocomplete
Settings↗
Settings
Help↗
Help

QR codes and base45

A QR code can store text in a few modes. Byte mode costs 8 bits per character. Alphanumeric mode only knows 45 characters - digits, capitals, space and $%*+-./: - but packs two of them in 11 bits, so 5.5 bits per character. base64url needs lowercase letters, so its QR code always ends up in byte mode, spending 8 bits on every 6 bits of data.

densing can therefore also write the QR alphabet. It is called base45, though it only uses the url safe part of those 45 characters: digits, capitals, - and the dot. The string gets a bit longer, but every character only costs 5.5 bits in the code. The link in the QR code of the PDF is written in it, entirely in capitals, so that the whole url stays alphanumeric.

For the example definition with one changed input: the normal link is 192 characters and needs a 49 x 49 QR code (version 8), the QR link is 207 characters and fits in 45 x 45 (version 7).

Definition schema, 428 bits as 72 base64url characters, 576 bits in a QR code↗
Definition schema, 428 bits as 72 base64url characters, 576 bits in a QR code
The same data as 82 base45 characters, 451 bits in a QR code↗
The same data as 82 base45 characters, 451 bits in a QR code
PDF export, the QR code holds the base45 link↗
PDF export, the QR code holds the base45 link