Stax 1.1.6
Stax 1.1.6
The web UI some changes.
- A syntax for compressed integer literals is introduced. They look like string literals followed by
%
, which previously calculated the literal length. For example8479773284726973836978
can be represented by" s3BqIr!fqmn"%
. Don't worry about why; there's a tool to convert for you. - There's a new "Tools" panel in the web UI where the perma-link options, compression tools, and examples have been moved.
- There are a few additional tools in there too.
- Layout options to move around the input and debug panes
- New literal compressions: single integer (as mentioned above) and unicode-aware string compressor. e.g.
"π is a fundamental constant"
is "compressed" to"sru1&WI(l&G(G&Q]?K/QCE9pM(]&KQ'5%pU:"!
, which doesn't really look shorter. But it is ASCII, so a program that includes it can still be packed. - There is a button to compress all literals in a program inline. For instance
"code"P"golf"P
will turn into`~x`P`K0!`P
. It might be a little buggy.
- On load, the web UI will attempt to load the last program out of
sessionStorage
. This might be useful if you accidentally navigated away before saving a stax masterpiece, or perhaps a staxterpiece.
There are also some new instructions and bug fixes.
- New instruction:
|j
"rationalizes" a floating point number. For example1.8
->9/5
. Internally, this uses a Stern-Brocot binary search, only slightly different. This instruction represents the majority of effort in this release, even though it's only a few lines of code. - New instruction:
|N
gets the rounded-down nth root of a number. For example130 3
->5
. - New instruction:
:a
gets the binary representation of a number as a string, in a specified fixed width. For example22 8
->"00010110"
. - And another one for hexadecimal:
:h
. For example30 4
->"001e"
- New instruction:
:N
tests whether an integer is a specified nth power. For example,64 6
->1
. - Bug fix: When a shorthand generator is followed by an unbalanced trailing
}
, the default generator block^
was not applied. This is probably the most esoteric and pointless stax bug that will ever exist. Maybe? Anyway,1{G}g3}2%
now correctly produces 1, 3, 5 instead of 1, 1, 1. - Bug fix:
|q
for integer square root was inaccurate for very large values. It was implemented using 64-bit floats. Obviously that was never going to work. 1.2e3
-style floating point literals can be understood by the implicit input eval, as well as thee
instruction.- In regex replace
R
, when a block is used for the replacer, numbers are now implicitly converted to strings, eliminating the need to use$
to convert to string. - The modulus instruction
%
returns the first operand when the second is zero. It just felt right. - The multiplicity operator
:/
is supposed to test the number of times that one number can evenly divide another. When the first number is zero, just return infinity rather than looping forever.