Skip to content

The Monster Update

Compare
Choose a tag to compare
@ETHproductions ETHproductions released this 31 May 19:32
· 185 commits to master since this release

Whew! I've done a lot since v1.4.3 was released at the end of January. It's now the end of May, so let's see what all has been accomplished in 4 months:

General added features

  • Added 5 shortcuts: Å (s1 ), Æ (o@), Ç (o_), È (XYZ{X), É (-1)
  • Added the %L character class (matches anything but A-Za-z).
  • Added experimental permutation and combination functions using caches (not enabled though); the new permutation function seems to be way faster than the old on large arrays, but the new combination function is slower.
  • Added shims for String.prototype.contains, Array.prototype.contains, and Math.trunc so I can safely use them throughout the code.
  • Added flags (see below for a list).
  • Any of a-zà-ÿ*/%^|&<=>? after a semicolon is now prepended with a U. (This already happened at the beginning of a program or function)

Bug fixes/improvements

  • regexify(x) fails if x is not a string or a regex.
  • Arrays don't show up in the output of the str() function (hence str(1) and str([[[1]]]) both return "1").
  • Literal strings are returned verbatim from the str() function (as opposed to String objects, which are wrapped in quotes).
  • A.r() fails if given an auto-function without a second parameter.
  • S.m() does not properly accept three arguments (e.g. "abc de f"mp2S -> "abcabc dede ff").
  • Fixed numerous bugs where large numbers would be destroyed due to use of |0 for truncation.
  • Fixed code for M.q() and M.r() so that they actually do what they're supposed to.
  • Centralized all code for N.ò(), N.ó(), and N.ô() in N.o() to fix some inconsistencies.
  • \x (where x is any char) transpiles to a number if within a function.
  • # at the end of the program throws a transpile-time error.
  • There are often unnecessary double parentheses in the output.
  • Nested compressed strings don't end implicitly.
  • 5.5.5, A.5, 1e2e3, etc. are transpiled verbatim.

New String methods

  • S.a(f) and S.b(f); these return the first/last index where f returns a truthy value.
  • S.c(f); this works like S.m(f), but on char-codes.
  • S.ç(s=" "): replaces each char in this with s.
  • S.ê(n=0): if n%2 < 1, mirrors this around its last character; otherwise, appends its reverse.
  • S.ê(s): returns true if this is a palindrome (i.e. equal to its reverse); false otherwise.
  • S.î(s=" "): repeats s until it reaches this.length.
  • S.ò(n=2); cuts this into slices of length n. "abcde"ò2 -> ["ab","cd","e"]
  • S.ò(f); partitions this between chars X, Y where f(X,Y) is truthy. "abba"ò@X<Y} -> ["a","bba"].
  • S.ó(n=2); cuts this into n arrays of every nth char. "abcde"ó2 -> ["ace","bd"]
  • S.ó(f); partitions this between chars X, Y where f(X,Y) is falsy. "abbc"ó@X<Y} -> ["ab","bc"].
  • S.ô(f); partitions this at chars X where f(X) is truthy. "abca"ô@X>'b} -> ["ab","a"]
  • S.ö(); returns a random character of this.
  • S.ö(n); returns a string of ceil(n) random characters of this (with replacement).
  • S.ö(x); returns a random permutation of this.
  • S.ø(s); returns true if this contains s, false otherwise.
  • S.ø(a); returns true if this contains any element of a, false otherwise.

New Array methods

  • A.a(f) and A.b(f); these return the first/last index where f returns a truthy value.
  • A.f(a,n=0):
    • if n%3 === 0, selects the items in this that are also contained in a;
    • if n%3 === 2, selects each item contained in both this and a;
    • if n%3 === 1, selects each item that can be removed from both this and a.
  • A.k(a); removes all items in a from this.
  • A.x(f); performs A.m(f) then takes the sum.
  • A.ê(n=0): if n%2 < 1, mirrors this around its last item; otherwise, appends its reverse.
  • A.ê(s): returns true if this is a palindrome (i.e. equal to its reverse); false otherwise.
  • A.í(n=10): converts this from an array of base-n digits to a decimal number.
  • A.î(a=[0]): repeats a until it reaches this.length.
  • A.ò(n=2); cuts this into slices of length n. [1,2,3,4,5]ò2 -> [[1,2],[3,4],[5]]
  • A.ò(f); partitions this between items X, Y where f(X,Y) is truthy. [1,2,0,3]ò@X>Y} -> [[1,2],[0,3]]
  • A.ó(n=2); cuts this into n arrays of every nth char. [1,2,3,4,5]ò2 -> [[1,3,5],[2,4]]
  • A.ó(f); partitions this between items X, Y where f(X,Y) is falsy. [1,2,0,3]ò@X<Y} -> [[1,2],[0,3]]
  • A.ô(); partitions this at items X where X is falsy. [1,2,0,3]ô -> [[1,2],[3]]
  • A.ô(f); partitions this at items X where f(X) is truthy. [1,2,3,1]ô@X>2} -> [[1,2],[1]]
  • A.ö(); returns a random element of this.
  • A.ö(n); returns an array of ceil(n) random elements of this (with replacement).
  • A.ö(x); returns a random permutation of this.
  • A.ø(x); returns true if this contains x; false otherwise.
  • A.ø(a); returns true if this contains any element of a; false otherwise.

New Number methods

  • N.â(x?): returns all integer divisors of this. If x is truthy, doesn't include this.
  • N.ç(s=" "); repeats s this times.
  • N.î(s=" "); repeats s until it reaches length this.
  • N.õ(n=1,n=1); like o, but creates the range [n₁...this] (with step size of n₂), and the range is not reversed if this is less than n₁.
  • N.õ(f); maps each integer in [1...this] through f.
  • N.ö(); returns a random item of this.o().
  • N.ö(n); returns an array of ceil(n) random items of this.o() (with replacement).
  • N.ö(x); returns a random permutation of this.o().

New Math features

  • M.e: Math.exp
  • M.l: Math.log
  • M.m: Math.log2
  • M.n: Math.log10
  • M.T: tau (pi * 2)

New flags

  • -m: Map; runs the program on each item in the input, returning an array of the results. If the input is a number, it's turned into a range first; if the input is a string, it's split into chars beforehand and joined again afterwards.
  • -f: Filter; runs the program on each item in the input, returning an array of only the items that return a truthy value. If the input is a number, it's turned into a range first; if the input is a string, it's split into chars beforehand and joined again afterwards.
  • : A shortcut for -fg; runs the program on each item, returning the first one that returns a truthy value.
  • -d: Some; runs the program on each item, returning true if any returns a truthy value, false otherwise.
  • -e: Every; runs the program on each item, returning false if any returns a falsy value, true otherwise.
  • -g: Returns the first item in the output. If given a number (-g3), returns the nth item.
  • -h: Returns the last item in the output.
  • -!: Returns the boolean NOT of the output: true if the output is falsy; false otherwise.
  • : Converts to boolean: returns true if the output is truthy; false otherwise.
  • -N: Converts the output to a number.
  • -P: If the output is an array, outputs with no separator (i.e. joined with P).
  • -Q: Pretty-prints the output, wrapping strings in quotes and arrays in brackets.
  • -R: If the output is an array, outputs separated by newlines (i.e. joined with R).
  • -S: If the output is an array, outputs separated by spaces (i.e. joined with S).
  • -x: Calls .x() on the output. If the output is an array, sums; if the output is a string, trims whitespace from both ends.

The next big step is to clean up the code...