The Monster Update
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 butA-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
, andMath.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 aU
. (This already happened at the beginning of a program or function)
Bug fixes/improvements
regexify(x)
fails ifx
is not a string or a regex.- Arrays don't show up in the output of the
str()
function (hencestr(1)
andstr([[[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()
andM.r()
so that they actually do what they're supposed to. - Centralized all code for
N.ò()
,N.ó()
, andN.ô()
inN.o()
to fix some inconsistencies. \x
(wherex
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)
andS.b(f)
; these return the first/last index wheref
returns a truthy value.S.c(f)
; this works likeS.m(f)
, but on char-codes.S.ç(s=" ")
: replaces each char inthis
withs
.S.ê(n=0)
: ifn%2 < 1
, mirrorsthis
around its last character; otherwise, appends its reverse.S.ê(s)
: returnstrue
ifthis
is a palindrome (i.e. equal to its reverse);false
otherwise.S.î(s=" ")
: repeatss
until it reachesthis.length
.S.ò(n=2)
; cutsthis
into slices of lengthn
."abcde"ò2 -> ["ab","cd","e"]
S.ò(f)
; partitionsthis
between charsX, Y
wheref(X,Y)
is truthy."abba"ò@X<Y} -> ["a","bba"]
.S.ó(n=2)
; cutsthis
inton
arrays of everyn
th char."abcde"ó2 -> ["ace","bd"]
S.ó(f)
; partitionsthis
between charsX, Y
wheref(X,Y)
is falsy."abbc"ó@X<Y} -> ["ab","bc"]
.S.ô(f)
; partitionsthis
at charsX
wheref(X)
is truthy."abca"ô@X>'b} -> ["ab","a"]
S.ö()
; returns a random character ofthis
.S.ö(n)
; returns a string ofceil(n)
random characters ofthis
(with replacement).S.ö(x)
; returns a random permutation ofthis
.S.ø(s)
; returnstrue
ifthis
containss
,false
otherwise.S.ø(a)
; returnstrue
ifthis
contains any element ofa
,false
otherwise.
New Array methods
A.a(f)
andA.b(f)
; these return the first/last index wheref
returns a truthy value.A.f(a,n=0)
:- if
n%3 === 0
, selects the items inthis
that are also contained ina
; - if
n%3 === 2
, selects each item contained in boththis
anda
; - if
n%3 === 1
, selects each item that can be removed from boththis
anda
.
- if
A.k(a)
; removes all items ina
fromthis
.A.x(f)
; performsA.m(f)
then takes the sum.A.ê(n=0)
: ifn%2 < 1
, mirrorsthis
around its last item; otherwise, appends its reverse.A.ê(s)
: returnstrue
ifthis
is a palindrome (i.e. equal to its reverse);false
otherwise.A.í(n=10)
: convertsthis
from an array of base-n
digits to a decimal number.A.î(a=[0])
: repeatsa
until it reachesthis.length
.A.ò(n=2)
; cutsthis
into slices of lengthn
.[1,2,3,4,5]ò2 -> [[1,2],[3,4],[5]]
A.ò(f)
; partitionsthis
between itemsX, Y
wheref(X,Y)
is truthy.[1,2,0,3]ò@X>Y} -> [[1,2],[0,3]]
A.ó(n=2)
; cutsthis
inton
arrays of everyn
th char.[1,2,3,4,5]ò2 -> [[1,3,5],[2,4]]
A.ó(f)
; partitionsthis
between itemsX, Y
wheref(X,Y)
is falsy.[1,2,0,3]ò@X<Y} -> [[1,2],[0,3]]
A.ô()
; partitionsthis
at itemsX
whereX
is falsy.[1,2,0,3]ô -> [[1,2],[3]]
A.ô(f)
; partitionsthis
at itemsX
wheref(X)
is truthy.[1,2,3,1]ô@X>2} -> [[1,2],[1]]
A.ö()
; returns a random element ofthis
.A.ö(n)
; returns an array ofceil(n)
random elements ofthis
(with replacement).A.ö(x)
; returns a random permutation ofthis
.A.ø(x)
; returnstrue
ifthis
containsx
;false
otherwise.A.ø(a)
; returnstrue
ifthis
contains any element ofa
;false
otherwise.
New Number methods
N.â(x?)
: returns all integer divisors ofthis
. Ifx
is truthy, doesn't includethis
.N.ç(s=" ")
; repeatss
this
times.N.î(s=" ")
; repeatss
until it reaches lengththis
.N.õ(n=1,n=1)
; likeo
, but creates the range[n₁...this]
(with step size ofn₂
), and the range is not reversed ifthis
is less thann₁
.N.õ(f)
; maps each integer in[1...this]
throughf
.N.ö()
; returns a random item ofthis.o()
.N.ö(n)
; returns an array ofceil(n)
random items ofthis.o()
(with replacement).N.ö(x)
; returns a random permutation ofthis.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 withP
).-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 withR
).-S
: If the output is an array, outputs separated by spaces (i.e. joined withS
).-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...