Skip to content

Releases: ETHproductions/japt

The 2.0a0 Update

07 Jul 15:05
Compare
Choose a tag to compare
The 2.0a0 Update Pre-release
Pre-release

Mostly releasing this to match v1.4.5, so as not to break older answers. In addition to everything listed in the Overdue Update, includes several new features:

  • The code has been cleaned up enormously, and method definitions are no longer golfed (why did I even do that?).
  • Regex literals have been added, which auto-balance parentheses and brackets.
  • Backslashes now make single-class regex literals.
  • Division must now be done with ÷.

Also, 500 commits! Whoo!

The Overdue Update

07 Jul 06:54
Compare
Choose a tag to compare

I should release more often... I mean, 13 months? Really?

General added features

  • Added %c and %C character classes (consonants + y and anything else, respectively) (#50).
  • Added %p and %P character classes (printables and anything else, respectively).
  • Added %q and %Q character classes (printables + newline and anything else, respectively).
  • Added 7 shortcuts: Ê (l ), Ë (mDEF{D), Ì (gJ ), Í (n2 ), Î (g ), Ï (XYZ{Y), Ñ (*2).
  • Added Math.approx function, which rounds out errors of a magnitude less than 10n (default n = 5).
  • Each line except the last is now assigned to a variable, in order U, V, W, X, Y, Z, A, B, C, ... T (not that anyone will ever get anywhere near that far)

Bug fixes/improvements

  • S.e() used the g flag by default, breaking the effect of logging each successive replacement (#31).
  • A.o(n) assumed n was an integer, entering infinite loops if it wasn't (#37).
  • A.r(f) now starts with the first element if no starting value is given.
  • A.x() returned NaN if any of its elements couldn't be parsed as a number.
  • A.z(n) broke somehow. I think the fix broke it in a different way.
  • Auto-functions in A.ä(f) and A.å(f) didn't use both inputs.
  • A.ç(a) both modified A and filled the array with references rather than copies of a.
  • A.í(f,a) didn't swap arguments.
  • N.k(), N.ç(), and N.î() used this as a Number object rather than a pure number (#35).
  • N.v() now acts as if all numbers are divisible by 0.
  • Switched from String.fromCharCode to String.fromCodePoint (#42).
  • Added more implicit commas before decimal points.
  • General fixes with implicit Us.
  • General fixes with $interpolated JS$.
  • Balance parentheses inside ?:, adding an extra layer if necessary.
  • Make ++ and -- take precedence over anything else, adding a layer of parentheses.
  • Remove many unnecessary layers of parentheses to improve readability.
  • Add spacing to improve readability. (Only permanent side-effect is breaking The Polyglot)
  • More I haven't yet mentioned and don't remember.

New String methods

  • S.k(s); removes chars in s (opposite of S.o(s)).
  • S.k(f); removes chars that satisfy f (opposite of S.o(f)).
  • S.n(s); converts from base s.length to integer using s as the alphabet.
  • S.n(a); same as above, but with an array of items making up the alphabet.
  • S.o(f); keeps only the chars that satisfy f (similar to A.f(f)).
  • S.y(f); maps each column through f.
  • S.í(s,f?); pairs each char with the corresponding one in s, optionally mapping each pair through f.
  • S.ù/ú/û(n,s=" "); left/right/center-pads each line to length n with s.
  • S.ù/ú/û(s=" "); left/right/center-pads each line to form a rectangle.

New Array methods

  • A.e(a); returns whether the two arrays are equal (#42)
  • A.k(f); removes items that satisfy f (opposite of A.f(f)).
  • A.y(f); maps each column through f.
  • A.ì(s); converts from base s.length to integer using s as the alphabet.
  • A.ì(a); same as above, but with an array of items making up the alphabet.
  • A,ï(a,f?); Cartesian product, mapping each pair through f. If no a is given, uses A again.
  • A.ù/ú/û(n,s=" "); left/right/center-pads each line to length n with s.
  • A.ù/ú/û(s=" "); left/right/center-pads each line to form a rectangle.

New Number methods

  • N.a(n); absolute difference between N and n.
  • N.d(n); gets character at codepoint N+n.
  • N.j(n); whether N is coprime to n (they share no prime factors).
  • N.s(f); converts to string, maps through f, then converts back to number.
  • N.s(s); converts from integer to base s.length using s as the alphabet.
  • N.s(a); same as above, but with an array of items making up the alphabet.
  • N.y(n=2); GCD. (Even works on decimals, thanks to Math.approx!)
  • N.z(n=2); integer division.
  • N.ì(s); converts from integer to base s.length using s as the alphabet.
  • N.ì(a); same as above, but with an array of items making up the alphabet.

I should keep better track of my changes to make it easier to write these changelogs. Or maybe I could just release an update every few weeks or months so I don't forget what I've done...

The Monster Update

31 May 19:32
Compare
Choose a tag to compare

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...

More features, more fixes

30 Jan 15:17
Compare
Choose a tag to compare

One of the defining features of Japt is its lack of arity, so I've been trying to give more functions dual purposes depending on how many arguments they are given. You can see that here with A.c(), N.n(), and D.n().

  • Added feature: K now returns new Date() by default
  • Added feature: implicit U if first char is any of */%^|&<=>?
  • Added shortcuts: Ä (+1) and × (r*1 )
  • Added function: A.ñ(f) sorts A as if each value has been run through f
  • Added function: N.h(n=1) performs N.toPrecision(n)
  • Added function: N.x(n=0) performs N.toFixed(n)
  • Added function: D.n() casts D to a number, D.n(n) does the same as N.n(n)
  • Added function: F.c(f) is like F.a(f), but with all integers: 0, -1, 1, -2, 2, -3, 3...
  • Modified function: A.c(x) concatenates x to A
  • Modified function: N.n(n=0) returns n-N
  • Bug fix: A.n() always sorts lexicographically by default
  • Bug fix: auto-functions don't work with A.æ()
  • Bug fix: auto-functions don't work with N.o()
  • Bug fix: textboxes are emptied if URL contains no code= or input=

Added and improved a bunch of functions

06 Jan 19:27
Compare
Choose a tag to compare
  • Bug fix: à-ÿ are not accepted in shorthand functions
  • Bug fix: A.d(), A.e(), A.f(), and A.è() do not properly accept shorthand functions, e.g. f>2
  • Greatly improved the speed of A.æ() by returning as soon as the first item is found
  • Made N.j() (primality check) twice as fast
  • Combined N.h() with N.u() (positive modulus)
  • Made N.v() into a divisibility check
  • Added S.ë(n,x=0): returns every nth char of this, starting at index x
  • Added A.ë(n,x=0): returns every nth item of this, starting at index x
  • Added A.ì(x): converts this from an array of base-x digits to an integer
  • Added N.ì(x): converts this into an array of base-x digits
  • Added F.a(f?): returns the smallest non-negative integer that returns a truthy value when run through this, mapping through f beforehand
  • Added F.b(f?): like F.a(), but with bijective base-10 integers

Minor improvements and fixes

05 Jan 02:29
Compare
Choose a tag to compare
  • Added feature: implicit U added if the first char in the code is a lowercase letter
  • Bug fix: MP becomes M,P instead of M.P
  • Minor documentation improvements

See changes

Japt 1.4: too many improvements to list

04 Jan 21:01
Compare
Choose a tag to compare

This one's a biggy, stretching for more than a year and 205 commits. The main difference is that the internals have been completely rearranged, so the functions that were run and transpile before are now Japt.run and Japt.transpile. You can find all the differences here.

Japt 1.3: string compression, Unicode shortcuts, and many new functions

23 Nov 02:40
Compare
Choose a tag to compare

Over the last few days, vihanb and I have implemented a bunch of new features, bug fixes and enhancements:

  • String functions:
    • d - Recursive replace
    • e - Single-char replace and multiple-replace
    • o - Select chars
  • Array functions:
    • u - Unshift
    • v - Shift
  • Number functions:
    • a - absolute value
    • j - primality test
    • k - prime factorization
    • l - factorial
  • Math functions:
    • t - atan2
    • g - fibonacci
    • r - random
    • P - PI
  • String compression (using the shoco library):
    • Oc - compress ASCII text
    • Od - decompress pre-compressed text
    • text wrapped in backticks - auto-decompress
  • Unicode shortcuts:
    • ¡ - Um@
    • ¢ - Us2
    • £ - m@
    • ¤ - s2
    • ¥ - ==
    • ¦ - !=
    • § - <=
    • ¨ - >=
    • © - &&
    • ª - ||
    • « - &&!