diff --git a/05ab1e.js b/05ab1e.js index 042e7da..2205503 100644 --- a/05ab1e.js +++ b/05ab1e.js @@ -1,22 +1,22 @@ -;(_=>{ -let hc={'<':'<','&':'&',"'":''','"':'"'},he=x=>x.replace(/[<&'"]/g,c=>hc[c]) //html chars and escape fn -,tcs='' -,lbs=["ǝpop a,b,c\ninsert b into a on location c\n\n.ǝ\npop a\nprint a to STDERR","ʒpop a\nfilter a when the result of code == 1: usage ʒCODE}","αpop a,b\npush absolute difference of a and b","βpop a,b\npush a converted from base b (arbitrary)","γpop a\npush a split into chunks of consecutive equal elements","δpop a,b\nget the next command, push double vectorized command","εpop a\napply each on a: usage εCODE}","ζpop a,(b)\npush zipped a with filler b (standardized to space)","ηpop a\npush prefixes(a)","θpop a\npush a[-1]","вpop a,b\npush a converted to base b (arbitrary)","иpop a,b\npush a n-repeat (list-multiply) b","мpop a,b\npush a.remove(all elements of b)","нpop a\npush a[0]","тpush 100","Δpop a\nrepeat CODE until a doesn't change: usage ΔCODE}","Θpop a\npush 05AB1E truthified a (a == 1)","Σpop a\nsort a by the result of code: usage ΣCODE}","Ωpop a\npush random_pick(a)","≠pop a\npush 05AB1E falsified a (a != 1)","∊pop a\npush vertically mirrored a\n\n.∊\npop a\npush intersected vertical mirror a","∍pop a,b\npush a extended/shortened to length b","∞pop a\npush mirrored a\n\n.∞\npop a\npush intersected mirror a","₁push 256","₂push 26","₃push 95","₄push 1000","!pop a,\npush factorial(a)","\"start/end string literal","#pop a\nif true: break/end (used in infinite loops)\n\npop a\nif contains spaces, split on spaces","$push 1 and input (used for sequences)","%pop a,b\npush (a % b)","&pop a,b\npush a AND b","'push char ( 'a pushes \"a\" )","(pop a\npush -a",")wrap total stack to an array","*pop a,b\npush (a * b)","+pop a,b\npush (a + b)",",pop a\nprint(a)","-pop a,b\npush (a - b)","/pop a,b\npush (a / b)","0numeric literal\n\n.0\n\nthrow a division by zero error","1numeric literal","2numeric literal","3numeric literal","4numeric literal","5numeric literal","6numeric literal","7numeric literal","8numeric literal","9numeric literal",":pop a,b,c\na.replace(b, c) / infinite replacement\n\n.:\npop a,b,c\npush a.replace(b, c)",";pop a\npush a / 2\n\n.;\npop a,b,c\npush a.replace_first(b, c)","pop a\npush a + 1","?pop a\nprint a no newline","@pop a\npop and push the element at index a in the stack (leftmost element = index 0)","Apush 'abcdefghijklmnopqrstuvwxyz'\n\nžA\npush 512","Bpop a,b\npush base(a, b)\n\nžB\npush 1024","Cpop a\npush int(a, 2)\n\nžC\npush 2048","Dpop a\npush a, a\n\nžD\npush 4096","Epush eval(input())\n\nžE\npush 8192","Fpop a\nfor N in range(0, a) { }: F(commands)} / N = variable\n\nžF\npush 16384","Gpop a\nfor N in range(1, a) { }: F(commands)} / N = variable\n\nžG\npush 32768","Hpop a\npush int(a, 16)\n\nžH\npush 65536","Ipush input()\n\nžI\npush 2147483648","Jpop a\npush ''.join(a) if a is list / if not, then push ''.join(stack)\n\nžJ\npush 4294967296","Kpop a,b\npush a with no b's\n\nžK\npush [a-zA-Z0-9]","Lpop a\npush [1 .. a]\n\nžL\npush [z-aZ-A9-0]","Mpush the largest number in the stack\n\nžM\npush aeiou","Nreserved for variables\n\nžN\npush bcdfghjklmnpqrstvwxyz","Opop (a)\npush total sum of a if a is list, else total sum of stack\n\nžO\npush aeiouy","Ppop (a)\npush total product of a if a is list, else total product of stack\n\nžP\npush bcdfghjklmnpqrstvwxz","Qpop a,b\npush a == b (bool)\n\nžQ\npush printable ASCII character set (32-128)","Rpop a\npush reversed(a)\n\nžR\npush ABC","Spop a\npush all chars a seperate\n\n.S\npop a,b\npush 1 if a > b, -1 if a < b, 0 if a == b ","Tpush 10","Upop a\nassign X to a","Vpop a\nassign Y to a\n\n.V\npop a\nrun as 05AB1E code","Wpush min(a) without popping\n\n.W\npop a\nwait a milliseconds","Xinteger variable","Yinteger variable","Zpush max(a) without popping","[infinite loop start","\\delete last item","]close all loops and if statements","^pop a,b\npush a XOR b\n\n.^\npop a\ninsert a into global array with immediate sorting and after quit, print array[input_1]","_pop a\npush negative bool","`pop a\npush all the items of a into the stack","apop a\npush is_alpha(a)\n\nža\npush current hours","bpop a\npush bin(a)\n\nžb\npush current minutes","cpop a,b\npush a nCr b\n\nžc\npush current seconds","dpop a\npush is_number(a)\n\nžd\npush current microseconds","epop a,b\npush a nPr b\n\nže\npush current day","fpop a\npush list of prime factors (no duplicates)\n\nžf\npush current month","gpop a\npush length of a\n\nžg\npush current year","hpop a\npush hex(a)\n\nžh\npush [0-9]","ipop a\nif statement: iTHEN}: if true { then }\n\nži\npush [a-zA-Z]","jpop a\nSame as J, with each substring right justified w/ a length of b\n\nžj\npush [a-zA-Z0-9_]","kpop a,b\npush 0-indexed index of b in a (-1 when not found)\n\nžk\npush [z-aZ-A]","lpop a\npush lower_case(a)\n\nžl\npush [z-aZ-A9-0_]","mpop a,b\npush a**b\n\nžm\npush [9-0]","npop a\npush a**2\n\nžn\npush [A-Za-z]","opop a\npush 2**a\n\nžo\npush [Z-Az-a]","ppop a\npush isPrime(a)\n\nžp\npush [Z-A]","qterminates the program\n\nžq\npush pi","rreverse stack\n\nžr\npush e","spop a,b\npush b,a\n\nžs\npop a, push pi to a digits (max. 100000)","tpop a\npush sqrt(a)\n\nžt\npop a, push e to a digits (max. 10000)","upop a\npush upper_case(a)\n\nžu\npush ()<>[]{}","vpop a\nrange loop: for y in a (y = string, N = index)\n\nžv\npush 16","wwait one second\n\nžw\npush 32","xpop a\npush a, a * 2\n\nžx\npush 64","ypush string variable (used in mapping loops)\n\nžy\npush 128","zpop a\npush 1 / a\n\nžz\npush 256","{pop a\npush sorted a","|push the rest of input as an array with strings","}close a single if statement, loop, etc.","~pop a,b\npush a OR b","Ƶconvert the next char from base 255 to base 10 and add 101","€pop a\napply next command for each in a\n\n.€\npop a\ndebug printer (default encoding, fallbacks on cp1252)","Λpop a,b,c\nstore a canvas with {a: num, b: filler, c: pattern} (todo: docs)\n\n.Λ\npop a,b,c\nstore a canvas with {a: num, b: filler, c: pattern} and push the string to the stack","‚pop a,b\npush [a, b]","ƒpop a\npush for N in range(0, a + 1)","„2 char string / can also be used for 2 compressed strings","…3 char string / can also be used for 3 compressed strings","†pop a,b\npush a with b filtered to the front","‡pop a,b,c\npush a.transliterate(b -> c)","ˆpop a\nadd to global array\n\n.ˆ\npop a\ninsert a into global array and after quit, print array[input_1]","‰pop a,b\npush a divmod b","Špop a,b,c\npush c,a,b","‹pop a,b\npush a < b","Œpop a\npush substrings(a)\n\n.Œ\npop a,b\npush all possible ways to divide a into b pieces","Ćpop a\npush enclosed a: a + a[0]","Žbreak/end if stack is empty","ƶpop a\npush lifted a, each element is multiplied by its index (1-indexed)","Āpop a\npush truthified a","‘for compressed strings (upper)","’for compressed strings (no implicit space)","“for compressed strings (normal)","”for compressed strings (title)","•start/end a 1-9 char compressed string\n\n.•\n\ndecompress a base 255 alphabet based string","–pop a\nif 1, print N (used in loops)","—pop a\nif 1, print y (used in loops)","˜pop a\npush deep flattened a","™pop a\npush title_cased(a)","špop a\npush switch_cased(a)","›pop a,b\npush a > b","œpop a\npush permutations(a)\n\n.œ\npop a\npush partitions(a)","ćpop a\npush head_extracted a: a[1:], a[0] ","Ÿpop (a),b\npush [a, ..., b] if b not a list, otherwise push [b[0],...,b[1],...,b[n]]","āget a\npush range(1, len(a) + 1)","¡pop a,b\npush a.split(b)","¢pop a,b\npush a.count(b)","£pop a,b\npush a[0:b]\n\n.£\npop a,b\npush a[:-b]","¤get a\npush tail(a)","¥pop a\npush delta's a\n\n.¥\npop a\npush undelta a","¦pop a\npush a[1:]","§pop a\npush str(a)","¨pop a\npush a[0:-1]","©get a\nstore a in register_c without popping","ªpop a\npush sentence_cased(a)","«pop a,b\npush merged(a,b) if both are lists, else push concatenated(a, b)\n\n.«\nfoldr\nfolds a dyadic command between each element in a list from right to left","¬get a\npush head(a)","®push the last item from register_c","¯push global array","°pop a\npush 10 ** a","±pop a\npush bitwise not a","²push the second item from the input history\n\n.²\npop a\npush log_2(a)","³push the third item from the input history","´clear global array","µpop a\nwhile counter_variable != a, do...","¶push newline character","·pop a\npush 2 * a","¸pop a\npush [a]","¹push the first item from the input history","ºpush len(stack) > 0","»pop (a)\nif list, join list by newlines, else join stack by newlines\n\n.»\nfoldl\nfolds a dyadic command between each element in a list from right to left with opposite right/left operands","¼counter_variable += 1\n\n.¼\npop a\ntan(a)","½pop a,\nif 1, then counter_variable += 1\n\n.½\npop a\nsin(a)","¾push counter_variable\n\n.¾\npop a\ncos(a)","¿pop (a),b\npush gcd(b) if b is list, else push gcd([b, a])\n\n.¿\npop (a),b\npush lcm(b) if b is list, else push lcm(b, a)","Àpop a\npush a rotated 1 left\n\n.À\n\nrotate stack 1 left","Ápop a\npush a rotated 1 right\n\n.Á\n\nrotate stack 1 right","Âpop a\npush a, reversed(a)","Ãpop a,b\npush a.keep(b)","Äpop a\npush abs(a)","Ålist commands","Æpop a\npush reduced_substraction(a) if a is list, else reduced_substraction(stack)","Çpop a\npush ASCII value of a","Èpop a\npush a % 2 == 0 (is even)","Épop a\npush a % 2 == 1 (is uneven)","Êpop a,b\npush a != b","Ëpop a\npush 1 if all equal else 0","Ìpop a\npush a + 2","Ípop a\npush a - 2","Îpush 0 and input","Ïpop a,b\npush the elements from a at which the same index at b is 1","Ðpop a\ntriplicate top of stack (push a, push a, push a)","Ñpop a\npush divisors(a)","Òpop a\npush list of prime factors (with duplicates)","Ópop a\npush list of exponents of prime factors (2^a, 3^b, 5^c, 7^d, etc.)","Ôpop a\npush connected uniquified a","Õpop a\npush euler_totient(a)","Öpop a,b\npush a % b == 0","×pop a,b\npush a × b (strings)\n\n.×\npop a,b\npush the list a repeated b times","Øpop a\npush ath prime (zero-indexed)\n\n.Ø\npop a\npush 0-indexed number of the greatest prime ≤ a","Ùpop a\npush uniquified a","Úpop a\npush reverse uniquified a","Ûpop a,b\npush a with leading b's trimmed off","Üpop a,b\npush a with trailing b's trimmed off","Ýpop a\npush [0 .. a]","Þpop a\npush stringified float(a)","ßget a\nextract smallest element of list","àget a\nextract greatest element of list","ápop a\npush only letters of a","âpop a,b\npush cartesian product","ãpop (a),b\npush cartesian product of b.repeat(2) if b is list, else cartesian product of a.repeat(b)","äpop a,b\npush a sliced into b pieces\n\n.ä\npop a\ndebug printer (cp1252)","åpop a,b\npush b in a\n\n.å\npop a,b\npush b in a (vectorized results)","æpop a\npush powerset(a)\n\n.æ\npop a\ncompute permutations by function, usage: .æ}","çpop a\npush char a","èpop a,b\npush a[b]","épop a\npush sorted a (key=length)","êpop a\npush sorted_uniquified(a)","ëelse statement","ìpop a,b\npush merged(b, a) if both are lists, else a.prepend(b)","ípop a\npush [reversed Q for Q in a] (short for €R)","îpop a\npush round_up(a)","ïpop a\npush int(a)\n\n.ï\npop a\npush is int(a)","ðpush a space character","ñpop a,b,c\npush a + b merged with c as merge character","òpop a\npush round to nearest integer(a) (bankers rounding)\n\n.ò\npop a,b\nround a with b digits precision (bankers rounding)","ópop a\npush round_down(a)","ôpop a,b\npush a split in pieces of b","õpush empty string","öpop a,b\npush int(a, b)","÷pop a,b\npush a // b (integer division)","øpop (a),b\npush zipped b if b is list, else zipped a with b\n\n.ø\npop a,b\nsurround a with b","ùpop a,b\npush a with elements of length b","úpop a,b\npush a padded with b spaces in the front","ûpop a\npush palindromized(a), 12345 becomes 123454321 (a + a[::-1][1:])","üpairwise command (vectorizes if the first element is a list)","ýpop (a),b\npush b.join(a) if a is list, else b.join(stack)","þpop a\npush only digits of a","ÿused for string interpolation, pop a and replace ÿ with str(a)",".\ntwo char functions","ž\ntwo char functions"] -,bqk=''.replace(/∙/g,'') -,bqv=''.replace(/∙/g,'') -,tc={},bqc={} //tab completions and ` completions -for(let i=0;i') - for(let j=0;j'+lbs[i][0]+'' -} -let d=document,el=d.createElement('div');el.innerHTML= -`
${lbh}
- +; (_ => { + let hc = { '<': '<', '&': '&', "'": ''', '"': '"' }, he = x => x.replace(/[<&'"]/g, c => hc[c]) //html chars and escape fn + , tcs = '' + , lbs = ["ǝpop a,b,c\ninsert b into a on location c\n\n.ǝ\npop a\nprint a to STDERR", "ʒpop a\nfilter a when the result of code == 1: usage ʒCODE}", "αpop a,b\npush absolute difference of a and b", "βpop a,b\npush a converted from base b (arbitrary)", "γpop a\npush a split into chunks of consecutive equal elements", "δpop a,b\nget the next command, push double vectorized command", "εpop a\napply each on a: usage εCODE}", "ζpop a,(b)\npush zipped a with filler b (standardized to space)", "ηpop a\npush prefixes(a)", "θpop a\npush a[-1]", "вpop a,b\npush a converted to base b (arbitrary)", "иpop a,b\npush a n-repeat (list-multiply) b", "мpop a,b\npush a.remove(all elements of b)", "нpop a\npush a[0]", "тpush 100", "Δpop a\nrepeat CODE until a doesn't change: usage ΔCODE}", "Θpop a\npush 05AB1E truthified a (a == 1)", "Σpop a\nsort a by the result of code: usage ΣCODE}", "Ωpop a\npush random_pick(a)", "≠pop a\npush 05AB1E falsified a (a != 1)", "∊pop a\npush vertically mirrored a\n\n.∊\npop a\npush intersected vertical mirror a", "∍pop a,b\npush a extended/shortened to length b", "∞pop a\npush mirrored a\n\n.∞\npop a\npush intersected mirror a", "₁push 256", "₂push 26", "₃push 95", "₄push 1000", "!pop a,\npush factorial(a)", "\"start/end string literal", "#pop a\nif true: break/end (used in infinite loops)\n\npop a\nif contains spaces, split on spaces", "$push 1 and input (used for sequences)", "%pop a,b\npush (a % b)", "&pop a,b\npush a AND b", "'push char ( 'a pushes \"a\" )", "(pop a\npush -a", ")wrap total stack to an array", "*pop a,b\npush (a * b)", "+pop a,b\npush (a + b)", ",pop a\nprint(a)", "-pop a,b\npush (a - b)", "/pop a,b\npush (a / b)", "0numeric literal\n\n.0\n\nthrow a division by zero error", "1numeric literal", "2numeric literal", "3numeric literal", "4numeric literal", "5numeric literal", "6numeric literal", "7numeric literal", "8numeric literal", "9numeric literal", ":pop a,b,c\na.replace(b, c) / infinite replacement\n\n.:\npop a,b,c\npush a.replace(b, c)", ";pop a\npush a / 2\n\n.;\npop a,b,c\npush a.replace_first(b, c)", "pop a\npush a + 1", "?pop a\nprint a no newline", "@pop a\npop and push the element at index a in the stack (leftmost element = index 0)", "Apush 'abcdefghijklmnopqrstuvwxyz'\n\nžA\npush 512", "Bpop a,b\npush base(a, b)\n\nžB\npush 1024", "Cpop a\npush int(a, 2)\n\nžC\npush 2048", "Dpop a\npush a, a\n\nžD\npush 4096", "Epush eval(input())\n\nžE\npush 8192", "Fpop a\nfor N in range(0, a) { }: F(commands)} / N = variable\n\nžF\npush 16384", "Gpop a\nfor N in range(1, a) { }: F(commands)} / N = variable\n\nžG\npush 32768", "Hpop a\npush int(a, 16)\n\nžH\npush 65536", "Ipush input()\n\nžI\npush 2147483648", "Jpop a\npush ''.join(a) if a is list / if not, then push ''.join(stack)\n\nžJ\npush 4294967296", "Kpop a,b\npush a with no b's\n\nžK\npush [a-zA-Z0-9]", "Lpop a\npush [1 .. a]\n\nžL\npush [z-aZ-A9-0]", "Mpush the largest number in the stack\n\nžM\npush aeiou", "Nreserved for variables\n\nžN\npush bcdfghjklmnpqrstvwxyz", "Opop (a)\npush total sum of a if a is list, else total sum of stack\n\nžO\npush aeiouy", "Ppop (a)\npush total product of a if a is list, else total product of stack\n\nžP\npush bcdfghjklmnpqrstvwxz", "Qpop a,b\npush a == b (bool)\n\nžQ\npush printable ASCII character set (32-128)", "Rpop a\npush reversed(a)\n\nžR\npush ABC", "Spop a\npush all chars a seperate\n\n.S\npop a,b\npush 1 if a > b, -1 if a < b, 0 if a == b ", "Tpush 10", "Upop a\nassign X to a", "Vpop a\nassign Y to a\n\n.V\npop a\nrun as 05AB1E code", "Wpush min(a) without popping\n\n.W\npop a\nwait a milliseconds", "Xinteger variable", "Yinteger variable", "Zpush max(a) without popping", "[infinite loop start", "\\delete last item", "]close all loops and if statements", "^pop a,b\npush a XOR b\n\n.^\npop a\ninsert a into global array with immediate sorting and after quit, print array[input_1]", "_pop a\npush negative bool", "`pop a\npush all the items of a into the stack", "apop a\npush is_alpha(a)\n\nža\npush current hours", "bpop a\npush bin(a)\n\nžb\npush current minutes", "cpop a,b\npush a nCr b\n\nžc\npush current seconds", "dpop a\npush is_number(a)\n\nžd\npush current microseconds", "epop a,b\npush a nPr b\n\nže\npush current day", "fpop a\npush list of prime factors (no duplicates)\n\nžf\npush current month", "gpop a\npush length of a\n\nžg\npush current year", "hpop a\npush hex(a)\n\nžh\npush [0-9]", "ipop a\nif statement: iTHEN}: if true { then }\n\nži\npush [a-zA-Z]", "jpop a\nSame as J, with each substring right justified w/ a length of b\n\nžj\npush [a-zA-Z0-9_]", "kpop a,b\npush 0-indexed index of b in a (-1 when not found)\n\nžk\npush [z-aZ-A]", "lpop a\npush lower_case(a)\n\nžl\npush [z-aZ-A9-0_]", "mpop a,b\npush a**b\n\nžm\npush [9-0]", "npop a\npush a**2\n\nžn\npush [A-Za-z]", "opop a\npush 2**a\n\nžo\npush [Z-Az-a]", "ppop a\npush isPrime(a)\n\nžp\npush [Z-A]", "qterminates the program\n\nžq\npush pi", "rreverse stack\n\nžr\npush e", "spop a,b\npush b,a\n\nžs\npop a, push pi to a digits (max. 100000)", "tpop a\npush sqrt(a)\n\nžt\npop a, push e to a digits (max. 10000)", "upop a\npush upper_case(a)\n\nžu\npush ()<>[]{}", "vpop a\nrange loop: for y in a (y = string, N = index)\n\nžv\npush 16", "wwait one second\n\nžw\npush 32", "xpop a\npush a, a * 2\n\nžx\npush 64", "ypush string variable (used in mapping loops)\n\nžy\npush 128", "zpop a\npush 1 / a\n\nžz\npush 256", "{pop a\npush sorted a", "|push the rest of input as an array with strings", "}close a single if statement, loop, etc.", "~pop a,b\npush a OR b", "Ƶconvert the next char from base 255 to base 10 and add 101", "€pop a\napply next command for each in a\n\n.€\npop a\ndebug printer (default encoding, fallbacks on cp1252)", "Λpop a,b,c\nstore a canvas with {a: num, b: filler, c: pattern} (todo: docs)\n\n.Λ\npop a,b,c\nstore a canvas with {a: num, b: filler, c: pattern} and push the string to the stack", "‚pop a,b\npush [a, b]", "ƒpop a\npush for N in range(0, a + 1)", "„2 char string / can also be used for 2 compressed strings", "…3 char string / can also be used for 3 compressed strings", "†pop a,b\npush a with b filtered to the front", "‡pop a,b,c\npush a.transliterate(b -> c)", "ˆpop a\nadd to global array\n\n.ˆ\npop a\ninsert a into global array and after quit, print array[input_1]", "‰pop a,b\npush a divmod b", "Špop a,b,c\npush c,a,b", "‹pop a,b\npush a < b", "Œpop a\npush substrings(a)\n\n.Œ\npop a,b\npush all possible ways to divide a into b pieces", "Ćpop a\npush enclosed a: a + a[0]", "Žbreak/end if stack is empty", "ƶpop a\npush lifted a, each element is multiplied by its index (1-indexed)", "Āpop a\npush truthified a", "‘for compressed strings (upper)", "’for compressed strings (no implicit space)", "“for compressed strings (normal)", "”for compressed strings (title)", "•start/end a 1-9 char compressed string\n\n.•\n\ndecompress a base 255 alphabet based string", "–pop a\nif 1, print N (used in loops)", "—pop a\nif 1, print y (used in loops)", "˜pop a\npush deep flattened a", "™pop a\npush title_cased(a)", "špop a\npush switch_cased(a)", "›pop a,b\npush a > b", "œpop a\npush permutations(a)\n\n.œ\npop a\npush partitions(a)", "ćpop a\npush head_extracted a: a[1:], a[0] ", "Ÿpop (a),b\npush [a, ..., b] if b not a list, otherwise push [b[0],...,b[1],...,b[n]]", "āget a\npush range(1, len(a) + 1)", "¡pop a,b\npush a.split(b)", "¢pop a,b\npush a.count(b)", "£pop a,b\npush a[0:b]\n\n.£\npop a,b\npush a[:-b]", "¤get a\npush tail(a)", "¥pop a\npush delta's a\n\n.¥\npop a\npush undelta a", "¦pop a\npush a[1:]", "§pop a\npush str(a)", "¨pop a\npush a[0:-1]", "©get a\nstore a in register_c without popping", "ªpop a\npush sentence_cased(a)", "«pop a,b\npush merged(a,b) if both are lists, else push concatenated(a, b)\n\n.«\nfoldr\nfolds a dyadic command between each element in a list from right to left", "¬get a\npush head(a)", "®push the last item from register_c", "¯push global array", "°pop a\npush 10 ** a", "±pop a\npush bitwise not a", "²push the second item from the input history\n\n.²\npop a\npush log_2(a)", "³push the third item from the input history", "´clear global array", "µpop a\nwhile counter_variable != a, do...", "¶push newline character", "·pop a\npush 2 * a", "¸pop a\npush [a]", "¹push the first item from the input history", "ºpush len(stack) > 0", "»pop (a)\nif list, join list by newlines, else join stack by newlines\n\n.»\nfoldl\nfolds a dyadic command between each element in a list from right to left with opposite right/left operands", "¼counter_variable += 1\n\n.¼\npop a\ntan(a)", "½pop a,\nif 1, then counter_variable += 1\n\n.½\npop a\nsin(a)", "¾push counter_variable\n\n.¾\npop a\ncos(a)", "¿pop (a),b\npush gcd(b) if b is list, else push gcd([b, a])\n\n.¿\npop (a),b\npush lcm(b) if b is list, else push lcm(b, a)", "Àpop a\npush a rotated 1 left\n\n.À\n\nrotate stack 1 left", "Ápop a\npush a rotated 1 right\n\n.Á\n\nrotate stack 1 right", "Âpop a\npush a, reversed(a)", "Ãpop a,b\npush a.keep(b)", "Äpop a\npush abs(a)", "Ålist commands", "Æpop a\npush reduced_substraction(a) if a is list, else reduced_substraction(stack)", "Çpop a\npush ASCII value of a", "Èpop a\npush a % 2 == 0 (is even)", "Épop a\npush a % 2 == 1 (is uneven)", "Êpop a,b\npush a != b", "Ëpop a\npush 1 if all equal else 0", "Ìpop a\npush a + 2", "Ípop a\npush a - 2", "Îpush 0 and input", "Ïpop a,b\npush the elements from a at which the same index at b is 1", "Ðpop a\ntriplicate top of stack (push a, push a, push a)", "Ñpop a\npush divisors(a)", "Òpop a\npush list of prime factors (with duplicates)", "Ópop a\npush list of exponents of prime factors (2^a, 3^b, 5^c, 7^d, etc.)", "Ôpop a\npush connected uniquified a", "Õpop a\npush euler_totient(a)", "Öpop a,b\npush a % b == 0", "×pop a,b\npush a × b (strings)\n\n.×\npop a,b\npush the list a repeated b times", "Øpop a\npush ath prime (zero-indexed)\n\n.Ø\npop a\npush 0-indexed number of the greatest prime ≤ a", "Ùpop a\npush uniquified a", "Úpop a\npush reverse uniquified a", "Ûpop a,b\npush a with leading b's trimmed off", "Üpop a,b\npush a with trailing b's trimmed off", "Ýpop a\npush [0 .. a]", "Þpop a\npush stringified float(a)", "ßget a\nextract smallest element of list", "àget a\nextract greatest element of list", "ápop a\npush only letters of a", "âpop a,b\npush cartesian product", "ãpop (a),b\npush cartesian product of b.repeat(2) if b is list, else cartesian product of a.repeat(b)", "äpop a,b\npush a sliced into b pieces\n\n.ä\npop a\ndebug printer (cp1252)", "åpop a,b\npush b in a\n\n.å\npop a,b\npush b in a (vectorized results)", "æpop a\npush powerset(a)\n\n.æ\npop a\ncompute permutations by function, usage: .æ}", "çpop a\npush char a", "èpop a,b\npush a[b]", "épop a\npush sorted a (key=length)", "êpop a\npush sorted_uniquified(a)", "ëelse statement", "ìpop a,b\npush merged(b, a) if both are lists, else a.prepend(b)", "ípop a\npush [reversed Q for Q in a] (short for €R)", "îpop a\npush round_up(a)", "ïpop a\npush int(a)\n\n.ï\npop a\npush is int(a)", "ðpush a space character", "ñpop a,b,c\npush a + b merged with c as merge character", "òpop a\npush round to nearest integer(a) (bankers rounding)\n\n.ò\npop a,b\nround a with b digits precision (bankers rounding)", "ópop a\npush round_down(a)", "ôpop a,b\npush a split in pieces of b", "õpush empty string", "öpop a,b\npush int(a, b)", "÷pop a,b\npush a // b (integer division)", "øpop (a),b\npush zipped b if b is list, else zipped a with b\n\n.ø\npop a,b\nsurround a with b", "ùpop a,b\npush a with elements of length b", "úpop a,b\npush a padded with b spaces in the front", "ûpop a\npush palindromized(a), 12345 becomes 123454321 (a + a[::-1][1:])", "üpairwise command (vectorizes if the first element is a list)", "ýpop (a),b\npush b.join(a) if a is list, else b.join(stack)", "þpop a\npush only digits of a", "ÿused for string interpolation, pop a and replace ÿ with str(a)", ".\ntwo char functions", "ž\ntwo char functions"] + , bqk = ''.replace(/∙/g, '') + , bqv = ''.replace(/∙/g, '') + , tc = {}, bqc = {} //tab completions and ` completions + for (let i = 0; i < bqk.length; i++)bqc[bqk[i]] = bqv[i] + for (let i = 0; i < tcs.length; i += 3)tc[tcs[i] + tcs[i + 1]] = tcs[i + 2] + for (let i = 0; i < tcs.length; i += 3) { let k = tcs[i + 1] + tcs[i]; tc[k] = tc[k] || tcs[i + 2] } + let lbh = ''; for (let i = 0; i < lbs.length; i++) { + let ks = [] + for (let j = 0; j < tcs.length; j += 3)if (lbs[i][0] === tcs[j + 2]) ks.push('\n' + tcs[j] + ' ' + tcs[j + 1] + ' ') + for (let j = 0; j < bqk.length; j++)if (lbs[i][0] === bqv[j]) ks.push('\n` ' + bqk[j]) + lbh += '' + lbs[i][0] + '' + } + let d = document, el = d.createElement('div'); el.innerHTML = + `
${lbh}
+ ` -d.body.appendChild(el) -let t,ts=[],lb=el.firstChild,bqm=0 //t:textarea or input, lb:language bar, bqm:backquote mode -let pd=x=>x.preventDefault() -let ev=(x,t,f,c)=>x.addEventListener(t,f,c) -ev(lb,'mousedown',x=>{ - if(x.target.classList.contains('ngn_x')){lb.hidden=1;upd();pd(x);return} - if(x.target.nodeName==='B'&&t){ - let i=t.selectionStart,j=t.selectionEnd,v=t.value,s=x.target.textContent - if(i!=null&&j!=null){t.value=v.slice(0,i)+s+v.slice(j);t.selectionStart=t.selectionEnd=i+s.length} - pd(x);return - } -}) -let fk=x=>{ - let t=x.target - if(bqm){let i=t.selectionStart,v=t.value,c=bqc[x.key];if(x.which>31){bqm=0;d.body.classList.remove('ngn_bq')} - if(c){t.value=v.slice(0,i)+c+v.slice(i);t.selectionStart=t.selectionEnd=i+1;pd(x);return!1}} - switch(x.ctrlKey+2*x.shiftKey+4*x.altKey+8*x.metaKey+100*x.which){ - case 900:{let i=t.selectionStart,v=t.value,c=tc[v.slice(i-2,i)] //tab - if(c){t.value=v.slice(0,i-2)+c+v.slice(i);t.selectionStart=t.selectionEnd=i-1;pd(x)} - break} - } -} -let ff=x=>{ - let t0=x.target,nn=t0.nodeName.toLowerCase() - if(nn!=='textarea'&&(nn!=='input'||t0.type!=='text'&&t0.type!=='search'))return - t=t0;if(!t.ngn){t.ngn=1;ts.push(t);ev(t,'keydown',fk)} -} -let upd=_=>{d.body.style.marginTop=lb.clientHeight+'px'} -upd();ev(window,'resize',upd) -ev(d,'focus',ff,!0);let ae=d.activeElement;ae&&ff({type:'focus',target:ae}) + d.body.appendChild(el) + let t, ts = [], lb = el.firstChild, bqm = 0 //t:textarea or input, lb:language bar, bqm:backquote mode + let pd = x => x.preventDefault() + let ev = (x, t, f, c) => x.addEventListener(t, f, c) + ev(lb, 'mousedown', x => { + if (x.target.classList.contains('ngn_x')) { lb.hidden = 1; upd(); pd(x); return } + if (x.target.nodeName === 'B' && t) { + let i = t.selectionStart, j = t.selectionEnd, v = t.value, s = x.target.textContent + if (i != null && j != null) { t.value = v.slice(0, i) + s + v.slice(j); t.selectionStart = t.selectionEnd = i + s.length } + pd(x); return + } + }) + let fk = x => { + let t = x.target + if (bqm) { + let i = t.selectionStart, v = t.value, c = bqc[x.key]; if (x.which > 31) { bqm = 0; d.body.classList.remove('ngn_bq') } + if (c) { t.value = v.slice(0, i) + c + v.slice(i); t.selectionStart = t.selectionEnd = i + 1; pd(x); return !1 } + } + switch (x.ctrlKey + 2 * x.shiftKey + 4 * x.altKey + 8 * x.metaKey + 100 * x.which) { + case 900: { + let i = t.selectionStart, v = t.value, c = tc[v.slice(i - 2, i)] //tab + if (c) { t.value = v.slice(0, i - 2) + c + v.slice(i); t.selectionStart = t.selectionEnd = i - 1; pd(x) } + break + } + } + } + let ff = x => { + let t0 = x.target, nn = t0.nodeName.toLowerCase() + if (nn !== 'textarea' && (nn !== 'input' || t0.type !== 'text' && t0.type !== 'search')) return + t = t0; if (!t.ngn) { t.ngn = 1; ts.push(t); ev(t, 'keydown', fk) } + } + let upd = _ => { d.body.style.marginTop = lb.clientHeight + 'px' } + upd(); ev(window, 'resize', upd) + ev(d, 'focus', ff, !0); let ae = d.activeElement; ae && ff({ type: 'focus', target: ae }) })(); diff --git a/Apl385.woff b/Apl385.woff deleted file mode 100644 index 0794d04..0000000 Binary files a/Apl385.woff and /dev/null differ diff --git a/DejaVuSansMono.ttf b/DejaVuBQNSansMono.ttf similarity index 74% rename from DejaVuSansMono.ttf rename to DejaVuBQNSansMono.ttf index f578602..070770d 100644 Binary files a/DejaVuSansMono.ttf and b/DejaVuBQNSansMono.ttf differ diff --git a/README.md b/README.md index fa67adb..6e0508f 100644 --- a/README.md +++ b/README.md @@ -2,6 +2,7 @@ 05AB1E Actually APL + Brachylog Husk Jelly diff --git a/actually.js b/actually.js index 6252743..11afe15 100644 --- a/actually.js +++ b/actually.js @@ -1,22 +1,22 @@ -;(_=>{ -let hc={'<':'<','&':'&',"'":''','"':'"'},he=x=>x.replace(/[<&'"]/g,c=>hc[c]) //html chars and escape fn -,tcs='' -,lbs=["○○\nread_byte\n push a single byte of unformatted input from STDIN (push sys.stdin.read(1))","◙◙\nwrite\n pop a: print a without a trailing newline","♂♂\nunary_map\n take the next command and map it over the top of the stack (for example, ♂A is equivalent to `A`M)","♀♀\nbinary_map\n take the next command and map it over the top 2 stack elements (like ♂ but for binary commands - ♀* is equivalent to Z`i*`M). If either of the top two stack elements are scalars (i.e. not iterables), it is reused for every element in the other iterable.","♫♫\nparallel_map\n take the next two commands and apply them each to the stack in parallel, and return the results as a list. If multiple values are output from a command, that output is nested in a list.","¶¶\niterate\n pop a: repeat the next command a times","§§\nread_all\n push all data from stdin as a string","▲▲\nlcm\n pop a,b: push lcm(a,b); pop [a]: push lcm([a])","▼▼\ngcd_reduce\n pop a,b: push b//gcd(a,b),a//gcd(a,b); pop [a]: push [x//gcd([a]) for x in [a]]"," \nstack_size\n push the # of elements on the stack (push len(stack))","!!\nfactorial\n pop a: push a! (factorial(a))","\"\"\nSYNTAX\n string literal, reads until next \" and pushes value onto stack. An implied \" is present at EOF if needed.","##\nlist\n pop a: push list(a)","$$\nstr\n pop a: push str(a)","%%\nmod\n pop a,b: push a%b; pop \"a\",[b]: push \"a\"%[b]","&&\nbitwise_and\n pop a,b: push (a & b)","''\nSYNTAX\n pushes next character onto stack as character literal (length-1 string)","((\nstack_rrot\n rotates stack right by 1","((\nstack_lrot\n: rotates stack left by 1","**\nmultiply\n pop a,b: push a*b; pop \"a\",b: repeat \"a\" b times, push \"a\" (\"a\"*b); pop a,[b] or [b],a: apply a* to each element in the array; pop [a],[b]: push dot product of [a] and [b] (sum([a[i]*b[i] for i in len(a)])) (shorter is padded with 0s)","++\nadd concat\n pop a,b: push a+b; pop \"a\",\"b\": push concatenation of \"a\" and \"b\"; pop [a],[b]: push [a][b] (append [b] to [a]); pop a,[b] or [b],a: apply a+ to each element in the array",",,\nread_line\n read value from stdin and push","--\nsubtract asymmetric_difference\n pop a,b: push a-b; pop [a],[b] (or \"a\",[b] or [a],\"b\" or \"a\",\"b\"): push [a]-[b] (all elements of [a] not in [b])","..\nprint write_line write_fn\n pop a: write a to stdout; pop f: f. (call f and execute . recursively)","//\ndivide list_rrot\n pop a,b: push a/b (float division); pop [a]: rotate [a] right by 1, push [a]","00\nSYNTAX\n push 0","11\nSYNTAX\n push 1","22\nSYNTAX\n push 2","33\nSYNTAX\n push 3","44\nSYNTAX\n push 4","55\nSYNTAX\n push 5","66\nSYNTAX\n push 6","77\nSYNTAX\n push 7","88\nSYNTAX\n push 8","99\nSYNTAX\n push 9","::\nSYNTAX\n numeric literal delimiter: pushes the longest string of characters in '0123456789+-.ij' as a numeric",";;\ncopy\n pop a: push a,a (duplicates top element)","<<\nless_than\n pop a,b: push 1 if a>\ngreater_than\n pop a,b: push 1 if a>b else 0","??\nSYNTAX\n NOP, extended expressions if -e flag is passed","@@\nswap\n pop a,b: push a,b (rotate top 2 elements)","AA\nabs\n pop a: push abs(a)","BB\nbinary_randrange\n pop a,b: push a random integer in [a,b) (randrange(a,b))","CC\ncos\n pop a: push cos(a)","DD\ndecrement stddev\n pop a: push a-1; pop [a]: push stddev([a])","EE\nerf element\n pop a: push erf(a); pop [a],b: push [a][b] (bth item in [a]) (also works for strings)","FF\nfib first\n pop a: push Fib(a) (Fib(0)=0, Fib(1)=Fib(2)=1); pop [a]: push a[0]","GG\nrandom\n push a random float in the range [0,1) (push random())","HH\nhello_world head\n if stack is empty: push \"Hello, World!\"; pop \"a\" or [a],b: push a[:b]","II\nconditional\n pop a,b,c: push b if a is truthy, else push c","JJ\nunary_randrange random_choice\n pop a: push a random integer in [0,a) (randrange(a)); pop [a] or \"a\": push a random element from [a] or \"a\" (random.choice([a]|\"a\"))","KK\nceil\n pop a: push ceil(a)","LL\nfloor\n pop a: push floor(a)","MM\nmap max\n pop f,[a], execute f for each element in [a], using the element as a temporary stack, push [a] (similar to map(f,[a])); pop [a]: push max([a])","NN\nnnbb last\n if stack is empty: push the lyrics to \"99 Bottles of Beer\"; pop [a]: push a[-1]","OO\nord ords\n pop \"a\" or [a]: push [ord(c) for each c in \"a\" or [a], starting from the end]. If a list is popped, it is flattened, and if it contains strings of length > 1, the strings are exploded in-place (\"ABC\" -> [65,66,67], [\"A\",\"B\",\"CD\"] -> [65,66,67,68])","PP\nnth_prime\n pop a: push the a-th prime (zero-indexed)","QQ\nquine\n if stack is empty: push the program's source code","RR\nscoped_call reverse upper_range\n pop f,[a]: call f, using [a] as a temporary stack, push [a]; pop \"a\" or [a]: push reversed value (\"a\".reverse() or [a][::-1]); pop a: push [1,2,...,a] (range(1,a+1))","SS\nsin sort\n pop a: push sin(a); pop \"a\" or [a]: push sorted(a)","TT\ntangent set_element\n pop a: push tan(a); pop [a],b,c: set [a][b] to c, push [a]","UU\nunion\n pop [a],[b]: push union of [a] and [b]","VV\nrandom_uniform slices\n pop a,b: push uniform(a,b) (random float between a and b); pop \"a\" or [a],b: push all slices of a of length 1 <= n <= b","WW\nwhile_begin while_end\n loop delimiter: peek top of stack, repeat code in loop while a evaluates to true","XX\ndiscard\n pop a: discard","YY\nlogical_negate fixed_point\n pop a: push !bool(a) (logical negate, opposite of b); pop f: call f until there is no change from the last call (fixed-point combinator)","ZZ\nzip zip_n\n pop [a],[b]: push zip([a],[b]); pop a, zip the next a lists","[[\nSYNTAX\n begin list literal, values are delimited by commas (,)","\\\\\nfloor_divide list_lrot\n pop a,b: push a/b (integer division); pop [a]: rotate [a] left by 1, push [a]","]]\nSYNTAX\n end list literal","^^\nxor\n pop a,b: push a XOR b","__\nln\n pop a: push ln(a); pop f, [a]: fold f over [a] (reduce)","``\nSYNTAX\n prefix for function literal of length 1 (`p is the same as ⌠p⌡)","aa\nstack_invert\n invert the stack ([a,b,c,d] -> [d,c,b,a])","bb\nbool\n pop a: push 0 if a==0 else 1; pop \"a\" or [a]: push 0 if len(a)==0 else 1; pop f: push 0 if len(f)==0 else 1","cc\nchr count\n pop a: push character at ordinal a%256; pop [a],b: push [a].count(b); pop \"a\",\"b\": push \"a\".count(\"b\"); pop f, [a]: push the number of elements in [a] where f puts a truthy value on top of the stack","dd\ndequeue divmod\n pop [a]: dequeue b from [a], push [a],b; pop a,b: push divmod(a,b) (a//b, a%b)","ee\nexp\n pop a: push exp(a)","ff\nfib_index format\n pop a: push the Fibonacci index of a if a is a Fibonacci number, else -1; pop \"a\",[b]: push \"a\".format(*[b])","gg\ngcd\n pop a,b: push gcd(a,b); pop [a]: push gcd([a])","hh\nl2_norm\n pop a,b: push sqrt(a*a+b*b) (Euclidean norm)","ii\nfloat flatten\n pop \"a\": push atof(a); pop [a]: push each element from [a], starting from end (flatten)","jj\njoin\n pop \"a\",[b]: push \"a\".join([b]) (converting values in [b] to strings with $ if necessary)","kk\nnest_all\n pop all elements from stack, convert to list (in the order they were on the stack, starting from the top), and push","ll\nlen\n pop \"a\" or [a] or f: push len(a) (or len(f))","mm\nmodf min\n pop a: push int(a),frac(a) (modf(a)); pop [a]: push min([a])","nn\nrepeat_n iterate_n\n pop a,b: push a b times; pop f,b: call f b times","oo\nappend prime_factorization\n pop [a],b: push b to [a], push [a]; pop a: push the prime factorization of |a| with multiplicity (18 -> [2, 3, 3], -5 -> [5])","pp\nis_prime pop\n pop a: push 1 if a is prime else 0; pop [a]: pop b from [a], push [a],b","qq\nenqueue\n pop [a],b: enqueue b in [a], push [a]","rr\nlower_range\n pop a: push [0,1,...,a-1] (range(0,a)); pop \"a\" or [a] or f: push [0,1,...,len(a)-1] (range(0,len(a))) (or range(0,len(f)))","ss\nsgn split\n pop a: push sgn(a); pop [a],[b]: push a list of sublists of [a] split by any occurrences of elements of [b] (with \"a\", the sublists are strings)","tt\ntail translate\n pop \"a\" or [a],b: push a[b:]; pop \"a\",\"b\",\"c\": push a.translate(str.maketrans(b,c))","uu\nincrement\n pop a: push a+1","vv\nrandom_seed\n pop a: seed the RNG with a (random.seed(a))","ww\nprime_factors_exp\n pop a: push the full positive prime factorization of |a| (18 -> [[2,1],[3,2]], -5 -> [[5,1]])","xx\nbinary_range splat_range\n pop a,b: push [a,b) (range(a,b)); pop [a]: push range(*a)","yy\nprime_factors\n pop a: push the positive prime factors of |a| (18 -> [2,3], -5 -> [5])","zz\nwrite_many\n pop a: repeat . a times (pop a times and print to stdout)","{{\nstack_rrot_n\n pop a: rotate stack right a times","||\nbitwise_or\n pop a,b: push (a | b)","}}\nstack_lrot_n\n pop a: rotate stack left a times","~~\nbitwise_negate\n pop a: push ~a (unary bitwise negate)","⌂⌂\nexit\n terminate the program (without implicit stack popping and printing)","ÇÇ\ncomplex\n pop a,b: push a+bi; pop [a]: pop pairs of real numerics b,c from [a] and push b+ci (appending 0 to [a] if len([a]) is odd)","üü\nwrite_all\n pop entire stack and print to stdout","éé\ndiscard_all\n pop entire stack (clear stack)","ââ\nasin\n pop a: push asin(a)","ää\nacos\n pop a: push acos(a)","àà\natan\n pop a: push atan(a)","åå\natan2\n pop a,b: push atan2(a,b)","çç\nasinh\n pop a: push asinh(a)","êê\nacosh\n pop a: push acosh(a)","ëë\natanh\n pop a: push atanh(a)","èè\nrepr\n pop a: push repr(a)","ïï\nimag_unit\n push i, the imaginary unit (sqrt(-1) or 0+1i)","îî\nimag_mult\n pop a, push 0+ai; pop [a], push [a] with every element multiplied by i","ìì\ninverse numerics\n pop a: push 1/a; pop [a]: push numerics from [a]","ÄÄ\nsinh\n pop a: push sinh(a)","ÅÅ\ncosh\n pop a: push cosh(a)","ÉÉ\ntanh\n pop a: push tanh(a)","ææ\nmean\n pop [a]: push mean([a])","ÆÆ\nreplace strings\n pop \"a\",\"b\",\"c\": push \"a\".replace(\"b\",\"c\"); pop [a]: push strings from [a]","ôô\nstrip\n pop \"a\": push \"a\".strip()","öö\nlstrip\n pop \"a\": push \"a\".lstrip()","òò\nrstrip\n pop \"a\": push \"a\".rstrip()","ûû\nupper\n pop \"a\": push \"a\".upper()","ùù\nlower\n pop \"a\": push \"a\".lower()","ÿÿ\ntitle\n pop \"a\": push \"a\".title()","ÖÖ\nswapcase\n pop \"a\": push \"a\".swapcase()","ÜÜ\nmode\n pop [a]: push mode([a])","¢¢\ntake_sign\n pop a,b: push abs(a)*sgn(b)","££\nfunction functions\n pop \"a\": push a function whose code is \"a\"; pop [a]: push functions from [a]","¥¥\npair_add\n pop [a],[b]: push the result of pairwise addition of [a] and [b], padding the shorter with 0s","₧₧\nphase\n pop z: push phase(z)","ƒƒ\ncall\n pop f: call f","áá\ncomplex_conjugate\n pop z: push the complex conjugate of z","íí\nfind\n pop [a],b: push [a].index(b) (0-based, -1 if not found)","óó\nconditional_exit\n pop a: if bool(a) push a, else terminate the program (conditional exit); terminate the program if the stack is empty","úú\nalpha_lower\n push the lowercase English alphabet (ordinals 97-122)","ññ\nenumerate\n pop [a]: push enumerate([a]) ([[i,a[i]] for i in range(len(a))])","ÑÑ\nlists\n pop [a]: push lists from [a]","ºº\ndegrees\n pop a: push degrees(a)","¿¿\nint_base\n pop [a],b: push int([a],b) (interpret [a] as a base-b int)","⌐⌐\nadd_two\n pop a: push a+2","¬¬\nsubtract_two\n pop a: push a-2","½½\nhalf\n pop a: push a/2 (float division)","¼¼\nquarter\n pop a: push a/4 (float division)","¡¡\nstr_base\n pop a,b: push a string representing a in base b","««\nstack_insert_up\n pop a,b: insert b at position a, indexed from the bottom of the stack","»»\nstack_insert_down\n pop a,b: insert b at position a, indexed from the top of the stack","░░\nfilter\n pop [a],[b]: push [[b][i] if [a][i] for i in len(b)], pads [a] with 0s if necessary; pop f,[b]: push values of [b] where f returns a truthy value","▒▒\ntotient\n pop a: push totient(a) (# of integers <= a that are coprime with a)","▓▓\nprime_pi\n pop a: push pi(a) (# of primes <= a)","││\nstack_dup\n duplicate stack ([a,b,c] => [a,b,c,a,b,c])","┤┤\ncoprime\n pop a,b: push 1 if a and b are coprime else 0","╡╡\nchunk_number\n pop [a],b: push a list containing b non-overlapping sublists of [a] (chunk by number)","╢╢\nrindex\n pop [a] or \"a\", b: push a.rindex(b) (last index of b in a)","╖╖\nreg0_add\n pop a: add a to the value in register 0 (equivalent to ╜+╗)","╕╕\nreg1_add\n pop a: add a to the value in register 1 (equivalent to ╛+╝)","╣╣\npascal_row\n pop a: push the ath row in Pascal's triangle","║║\nmiddle\n pop [a] or \"a\": push median([a]/\"a\") (using ordinals if string)","╗╗\nreg0_save\n pop a: save a in register 0","╝╝\nreg1_save\n pop a: save a in register 1","╜╜\nreg0_load\n push the value in register 0 (initially a 0)","╛╛\nreg1_load\n push the value in register 1 (initially the empty string)","┐┐\nregn_save\n pop a,b: push b to register a","└└\nregn_load\n pop a: push the value in register a","┴┴\nSYNTAX\n pop f,[a]: push cumulative reduce of f over [a]","┬┬\ntranspose\n pop a: push transpose(a) ([[1,2,3],[4,5,6]] -> [[1,4],[2,5],[3,6]])","├├\nbin\n pop a: push big-endian binary representation of a (bin(a) for ints, binary float data for floats, ascii_to_bin(a) for strings)","──\nhex\n pop a: push big-endian hexadecimal representation of a (same as 0xC3 but with hex)","┼┼\nstack_dup_each\n duplicate each element on stack ([a,b,c] => [a,a,b,b,c,c])","╞╞\nstack_dup_each_n\n pop a: make a total copies of each element on stack (3 [a,b,c] -> [a,a,a,b,b,b,c,c,c])","╟╟\nnest_n\n pop a: pop a elements and push a list containing those elements in their original order","╚╚\nshuffle\n pop [a]: push random.shuffle(a)","╔╔\nuniquify\n pop \"a\" or [a]: push uniquify(a)","╩╩\nreg_input\n read all input and push each to its own numbered register, starting with 0","╦╦\npi\n push pi","╠╠\ne\n push e","══\nis_unique\n pop \"a\" or [a], push 1 if all elements are unique else 0","╬╬\nwhile_call\n pop f: while value on top of stack is truthy (peek), call f","╧╧\ncombinations\n pop [a] or \"a\",b: push all b-length combinations of a","╨╨\npermutations\n pop [a] or \"a\",b: push all b-length permutations of a","╤╤\npow10\n pop a: push 10**a","╥╥\nlog10 log\n pop a: push log(a) (log base 10)","╙╙\npow2\n pop a: push 2**a","╘╘\nlog2 lg\n pop a: push lg(a) (log base 2)","╒╒\nln2\n push ln(2)","╓╓\nfirst_n_truthy\n pop f,n: push first n values where f(x) is truthy, starting with f(0) (the function is called each time with a stack only containing n)","╫╫\nre_im\n pop a: push Re(a), Im(a) (real and imaginary parts of a)","╪╪\nchunk_length\n pop [a],b: push a list containing each non-overlapping b-length sublist of [a] (chunk by length)","┘┘\nord_cp437\n pop a: push ord_cp437(a)","┌┌\nchr_cp437\n pop a: push chr_cp437(a)","██\nnCr\n pop a,b: push C(a,b) (aCb)","▄▄\nnPr\n pop a,b: push P(a,b) (aPb)","▌▌\nb64decode\n pop \"a\": push b64decode(\"a\")","▐▐\nb64encode\n pop \"a\": push b64encode(\"a\")","▀▀\nbase_digits\n pop a: push digits in base a","αα\nrepeat_each\n pop a,[b]: push a list containing all the elements of [b] repeated a times; pop a,b: push a list containing a copies of b","ßß\nnth_input\n pop a: push the ath input value (defaults to 0 if a is not an integer or is >= the number of inputs currently read (without consuming a), or if the stack is empty)","ΓΓ\ngamma\n pop a: push Gamma(a)","ππ\nproduct\n pop [a]: push product([a])","ΣΣ\nsum\n pop [a]: push sum([a])","σσ\ncumulative_sums\n pop [a]: push cumulative sums of [a]","µµ\nrms\n pop [a]: push rms (root-mean-square) of [a]","ττ\ndouble\n pop a: push 2*a","ΦΦ\nslice\n pop [a],b,c,d: push a[b:c:d]; pop [a],[b]: push a[b[0]:b[1]:b[2]] (list slicing)","δδ\ndig\n pop a: bring the (a mod len(stack))'th item on the stack to the top","∞∞\ntoggle_preserve preserve_on preserve_off\n toggle preserve mode; if on, stack items are peeked rather than popped; implicitly turned off at EOF","φφ\nphi\n push phi (golden ratio)","εε\nempty_string\n push \"\" (empty string)","∩∩\nintersection\n pop [a],[b]: push intersection of [a] and [b]","≡≡\neval\n pop a: push eval(a) (Python-style evaluation)","±±\nunary_negate swap_quotes\n pop a: push -a (unary negate); pop \"a\": push \"a\" with all single-quotes replaced with double quotes and vice-versa","≥≥\ngte\n pop a,b: push a>=b","≤≤\nlte\n pop a,b: push a<=b","⌠⌠\nfunc_begin\n begin function literal","⌡⌡\nfunc_end\n end function literal","÷÷\ndivisors\n pop a: push a list of all positive divisors of a that are less than or equal to a","≈≈\nint\n pop a: push int(a)","°°\nradians\n pop a: push radians(a)","∙∙\ncartesian_product cartesian_power\n pop [a],[b]: push Cartesian product of [a] and [b]; pop [a],b: push [a]^b (Cartesian product of b copies of [a])","√√\nsqrt\n pop a: push sqrt(a)","ⁿⁿ\npow\n pop a,b: push pow(a,b)","²²\nsquare\n pop a: push a*a","■■\nwrite_all_safe\n print the entire stack without popping, separated by spaces"] -,bqk=''.replace(/∙/g,'') -,bqv=''.replace(/∙/g,'') -,tc={},bqc={} //tab completions and ` completions -for(let i=0;i') - for(let j=0;j'+lbs[i][0]+'' -} -let d=document,el=d.createElement('div');el.innerHTML= -`
${lbh}
- +; (_ => { + let hc = { '<': '<', '&': '&', "'": ''', '"': '"' }, he = x => x.replace(/[<&'"]/g, c => hc[c]) //html chars and escape fn + , tcs = '' + , lbs = ["○○\nread_byte\n push a single byte of unformatted input from STDIN (push sys.stdin.read(1))", "◙◙\nwrite\n pop a: print a without a trailing newline", "♂♂\nunary_map\n take the next command and map it over the top of the stack (for example, ♂A is equivalent to `A`M)", "♀♀\nbinary_map\n take the next command and map it over the top 2 stack elements (like ♂ but for binary commands - ♀* is equivalent to Z`i*`M). If either of the top two stack elements are scalars (i.e. not iterables), it is reused for every element in the other iterable.", "♫♫\nparallel_map\n take the next two commands and apply them each to the stack in parallel, and return the results as a list. If multiple values are output from a command, that output is nested in a list.", "¶¶\niterate\n pop a: repeat the next command a times", "§§\nread_all\n push all data from stdin as a string", "▲▲\nlcm\n pop a,b: push lcm(a,b); pop [a]: push lcm([a])", "▼▼\ngcd_reduce\n pop a,b: push b//gcd(a,b),a//gcd(a,b); pop [a]: push [x//gcd([a]) for x in [a]]", " \nstack_size\n push the # of elements on the stack (push len(stack))", "!!\nfactorial\n pop a: push a! (factorial(a))", "\"\"\nSYNTAX\n string literal, reads until next \" and pushes value onto stack. An implied \" is present at EOF if needed.", "##\nlist\n pop a: push list(a)", "$$\nstr\n pop a: push str(a)", "%%\nmod\n pop a,b: push a%b; pop \"a\",[b]: push \"a\"%[b]", "&&\nbitwise_and\n pop a,b: push (a & b)", "''\nSYNTAX\n pushes next character onto stack as character literal (length-1 string)", "((\nstack_rrot\n rotates stack right by 1", "((\nstack_lrot\n: rotates stack left by 1", "**\nmultiply\n pop a,b: push a*b; pop \"a\",b: repeat \"a\" b times, push \"a\" (\"a\"*b); pop a,[b] or [b],a: apply a* to each element in the array; pop [a],[b]: push dot product of [a] and [b] (sum([a[i]*b[i] for i in len(a)])) (shorter is padded with 0s)", "++\nadd concat\n pop a,b: push a+b; pop \"a\",\"b\": push concatenation of \"a\" and \"b\"; pop [a],[b]: push [a][b] (append [b] to [a]); pop a,[b] or [b],a: apply a+ to each element in the array", ",,\nread_line\n read value from stdin and push", "--\nsubtract asymmetric_difference\n pop a,b: push a-b; pop [a],[b] (or \"a\",[b] or [a],\"b\" or \"a\",\"b\"): push [a]-[b] (all elements of [a] not in [b])", "..\nprint write_line write_fn\n pop a: write a to stdout; pop f: f. (call f and execute . recursively)", "//\ndivide list_rrot\n pop a,b: push a/b (float division); pop [a]: rotate [a] right by 1, push [a]", "00\nSYNTAX\n push 0", "11\nSYNTAX\n push 1", "22\nSYNTAX\n push 2", "33\nSYNTAX\n push 3", "44\nSYNTAX\n push 4", "55\nSYNTAX\n push 5", "66\nSYNTAX\n push 6", "77\nSYNTAX\n push 7", "88\nSYNTAX\n push 8", "99\nSYNTAX\n push 9", "::\nSYNTAX\n numeric literal delimiter: pushes the longest string of characters in '0123456789+-.ij' as a numeric", ";;\ncopy\n pop a: push a,a (duplicates top element)", "<<\nless_than\n pop a,b: push 1 if a>\ngreater_than\n pop a,b: push 1 if a>b else 0", "??\nSYNTAX\n NOP, extended expressions if -e flag is passed", "@@\nswap\n pop a,b: push a,b (rotate top 2 elements)", "AA\nabs\n pop a: push abs(a)", "BB\nbinary_randrange\n pop a,b: push a random integer in [a,b) (randrange(a,b))", "CC\ncos\n pop a: push cos(a)", "DD\ndecrement stddev\n pop a: push a-1; pop [a]: push stddev([a])", "EE\nerf element\n pop a: push erf(a); pop [a],b: push [a][b] (bth item in [a]) (also works for strings)", "FF\nfib first\n pop a: push Fib(a) (Fib(0)=0, Fib(1)=Fib(2)=1); pop [a]: push a[0]", "GG\nrandom\n push a random float in the range [0,1) (push random())", "HH\nhello_world head\n if stack is empty: push \"Hello, World!\"; pop \"a\" or [a],b: push a[:b]", "II\nconditional\n pop a,b,c: push b if a is truthy, else push c", "JJ\nunary_randrange random_choice\n pop a: push a random integer in [0,a) (randrange(a)); pop [a] or \"a\": push a random element from [a] or \"a\" (random.choice([a]|\"a\"))", "KK\nceil\n pop a: push ceil(a)", "LL\nfloor\n pop a: push floor(a)", "MM\nmap max\n pop f,[a], execute f for each element in [a], using the element as a temporary stack, push [a] (similar to map(f,[a])); pop [a]: push max([a])", "NN\nnnbb last\n if stack is empty: push the lyrics to \"99 Bottles of Beer\"; pop [a]: push a[-1]", "OO\nord ords\n pop \"a\" or [a]: push [ord(c) for each c in \"a\" or [a], starting from the end]. If a list is popped, it is flattened, and if it contains strings of length > 1, the strings are exploded in-place (\"ABC\" -> [65,66,67], [\"A\",\"B\",\"CD\"] -> [65,66,67,68])", "PP\nnth_prime\n pop a: push the a-th prime (zero-indexed)", "QQ\nquine\n if stack is empty: push the program's source code", "RR\nscoped_call reverse upper_range\n pop f,[a]: call f, using [a] as a temporary stack, push [a]; pop \"a\" or [a]: push reversed value (\"a\".reverse() or [a][::-1]); pop a: push [1,2,...,a] (range(1,a+1))", "SS\nsin sort\n pop a: push sin(a); pop \"a\" or [a]: push sorted(a)", "TT\ntangent set_element\n pop a: push tan(a); pop [a],b,c: set [a][b] to c, push [a]", "UU\nunion\n pop [a],[b]: push union of [a] and [b]", "VV\nrandom_uniform slices\n pop a,b: push uniform(a,b) (random float between a and b); pop \"a\" or [a],b: push all slices of a of length 1 <= n <= b", "WW\nwhile_begin while_end\n loop delimiter: peek top of stack, repeat code in loop while a evaluates to true", "XX\ndiscard\n pop a: discard", "YY\nlogical_negate fixed_point\n pop a: push !bool(a) (logical negate, opposite of b); pop f: call f until there is no change from the last call (fixed-point combinator)", "ZZ\nzip zip_n\n pop [a],[b]: push zip([a],[b]); pop a, zip the next a lists", "[[\nSYNTAX\n begin list literal, values are delimited by commas (,)", "\\\\\nfloor_divide list_lrot\n pop a,b: push a/b (integer division); pop [a]: rotate [a] left by 1, push [a]", "]]\nSYNTAX\n end list literal", "^^\nxor\n pop a,b: push a XOR b", "__\nln\n pop a: push ln(a); pop f, [a]: fold f over [a] (reduce)", "``\nSYNTAX\n prefix for function literal of length 1 (`p is the same as ⌠p⌡)", "aa\nstack_invert\n invert the stack ([a,b,c,d] -> [d,c,b,a])", "bb\nbool\n pop a: push 0 if a==0 else 1; pop \"a\" or [a]: push 0 if len(a)==0 else 1; pop f: push 0 if len(f)==0 else 1", "cc\nchr count\n pop a: push character at ordinal a%256; pop [a],b: push [a].count(b); pop \"a\",\"b\": push \"a\".count(\"b\"); pop f, [a]: push the number of elements in [a] where f puts a truthy value on top of the stack", "dd\ndequeue divmod\n pop [a]: dequeue b from [a], push [a],b; pop a,b: push divmod(a,b) (a//b, a%b)", "ee\nexp\n pop a: push exp(a)", "ff\nfib_index format\n pop a: push the Fibonacci index of a if a is a Fibonacci number, else -1; pop \"a\",[b]: push \"a\".format(*[b])", "gg\ngcd\n pop a,b: push gcd(a,b); pop [a]: push gcd([a])", "hh\nl2_norm\n pop a,b: push sqrt(a*a+b*b) (Euclidean norm)", "ii\nfloat flatten\n pop \"a\": push atof(a); pop [a]: push each element from [a], starting from end (flatten)", "jj\njoin\n pop \"a\",[b]: push \"a\".join([b]) (converting values in [b] to strings with $ if necessary)", "kk\nnest_all\n pop all elements from stack, convert to list (in the order they were on the stack, starting from the top), and push", "ll\nlen\n pop \"a\" or [a] or f: push len(a) (or len(f))", "mm\nmodf min\n pop a: push int(a),frac(a) (modf(a)); pop [a]: push min([a])", "nn\nrepeat_n iterate_n\n pop a,b: push a b times; pop f,b: call f b times", "oo\nappend prime_factorization\n pop [a],b: push b to [a], push [a]; pop a: push the prime factorization of |a| with multiplicity (18 -> [2, 3, 3], -5 -> [5])", "pp\nis_prime pop\n pop a: push 1 if a is prime else 0; pop [a]: pop b from [a], push [a],b", "qq\nenqueue\n pop [a],b: enqueue b in [a], push [a]", "rr\nlower_range\n pop a: push [0,1,...,a-1] (range(0,a)); pop \"a\" or [a] or f: push [0,1,...,len(a)-1] (range(0,len(a))) (or range(0,len(f)))", "ss\nsgn split\n pop a: push sgn(a); pop [a],[b]: push a list of sublists of [a] split by any occurrences of elements of [b] (with \"a\", the sublists are strings)", "tt\ntail translate\n pop \"a\" or [a],b: push a[b:]; pop \"a\",\"b\",\"c\": push a.translate(str.maketrans(b,c))", "uu\nincrement\n pop a: push a+1", "vv\nrandom_seed\n pop a: seed the RNG with a (random.seed(a))", "ww\nprime_factors_exp\n pop a: push the full positive prime factorization of |a| (18 -> [[2,1],[3,2]], -5 -> [[5,1]])", "xx\nbinary_range splat_range\n pop a,b: push [a,b) (range(a,b)); pop [a]: push range(*a)", "yy\nprime_factors\n pop a: push the positive prime factors of |a| (18 -> [2,3], -5 -> [5])", "zz\nwrite_many\n pop a: repeat . a times (pop a times and print to stdout)", "{{\nstack_rrot_n\n pop a: rotate stack right a times", "||\nbitwise_or\n pop a,b: push (a | b)", "}}\nstack_lrot_n\n pop a: rotate stack left a times", "~~\nbitwise_negate\n pop a: push ~a (unary bitwise negate)", "⌂⌂\nexit\n terminate the program (without implicit stack popping and printing)", "ÇÇ\ncomplex\n pop a,b: push a+bi; pop [a]: pop pairs of real numerics b,c from [a] and push b+ci (appending 0 to [a] if len([a]) is odd)", "üü\nwrite_all\n pop entire stack and print to stdout", "éé\ndiscard_all\n pop entire stack (clear stack)", "ââ\nasin\n pop a: push asin(a)", "ää\nacos\n pop a: push acos(a)", "àà\natan\n pop a: push atan(a)", "åå\natan2\n pop a,b: push atan2(a,b)", "çç\nasinh\n pop a: push asinh(a)", "êê\nacosh\n pop a: push acosh(a)", "ëë\natanh\n pop a: push atanh(a)", "èè\nrepr\n pop a: push repr(a)", "ïï\nimag_unit\n push i, the imaginary unit (sqrt(-1) or 0+1i)", "îî\nimag_mult\n pop a, push 0+ai; pop [a], push [a] with every element multiplied by i", "ìì\ninverse numerics\n pop a: push 1/a; pop [a]: push numerics from [a]", "ÄÄ\nsinh\n pop a: push sinh(a)", "ÅÅ\ncosh\n pop a: push cosh(a)", "ÉÉ\ntanh\n pop a: push tanh(a)", "ææ\nmean\n pop [a]: push mean([a])", "ÆÆ\nreplace strings\n pop \"a\",\"b\",\"c\": push \"a\".replace(\"b\",\"c\"); pop [a]: push strings from [a]", "ôô\nstrip\n pop \"a\": push \"a\".strip()", "öö\nlstrip\n pop \"a\": push \"a\".lstrip()", "òò\nrstrip\n pop \"a\": push \"a\".rstrip()", "ûû\nupper\n pop \"a\": push \"a\".upper()", "ùù\nlower\n pop \"a\": push \"a\".lower()", "ÿÿ\ntitle\n pop \"a\": push \"a\".title()", "ÖÖ\nswapcase\n pop \"a\": push \"a\".swapcase()", "ÜÜ\nmode\n pop [a]: push mode([a])", "¢¢\ntake_sign\n pop a,b: push abs(a)*sgn(b)", "££\nfunction functions\n pop \"a\": push a function whose code is \"a\"; pop [a]: push functions from [a]", "¥¥\npair_add\n pop [a],[b]: push the result of pairwise addition of [a] and [b], padding the shorter with 0s", "₧₧\nphase\n pop z: push phase(z)", "ƒƒ\ncall\n pop f: call f", "áá\ncomplex_conjugate\n pop z: push the complex conjugate of z", "íí\nfind\n pop [a],b: push [a].index(b) (0-based, -1 if not found)", "óó\nconditional_exit\n pop a: if bool(a) push a, else terminate the program (conditional exit); terminate the program if the stack is empty", "úú\nalpha_lower\n push the lowercase English alphabet (ordinals 97-122)", "ññ\nenumerate\n pop [a]: push enumerate([a]) ([[i,a[i]] for i in range(len(a))])", "ÑÑ\nlists\n pop [a]: push lists from [a]", "ºº\ndegrees\n pop a: push degrees(a)", "¿¿\nint_base\n pop [a],b: push int([a],b) (interpret [a] as a base-b int)", "⌐⌐\nadd_two\n pop a: push a+2", "¬¬\nsubtract_two\n pop a: push a-2", "½½\nhalf\n pop a: push a/2 (float division)", "¼¼\nquarter\n pop a: push a/4 (float division)", "¡¡\nstr_base\n pop a,b: push a string representing a in base b", "««\nstack_insert_up\n pop a,b: insert b at position a, indexed from the bottom of the stack", "»»\nstack_insert_down\n pop a,b: insert b at position a, indexed from the top of the stack", "░░\nfilter\n pop [a],[b]: push [[b][i] if [a][i] for i in len(b)], pads [a] with 0s if necessary; pop f,[b]: push values of [b] where f returns a truthy value", "▒▒\ntotient\n pop a: push totient(a) (# of integers <= a that are coprime with a)", "▓▓\nprime_pi\n pop a: push pi(a) (# of primes <= a)", "││\nstack_dup\n duplicate stack ([a,b,c] => [a,b,c,a,b,c])", "┤┤\ncoprime\n pop a,b: push 1 if a and b are coprime else 0", "╡╡\nchunk_number\n pop [a],b: push a list containing b non-overlapping sublists of [a] (chunk by number)", "╢╢\nrindex\n pop [a] or \"a\", b: push a.rindex(b) (last index of b in a)", "╖╖\nreg0_add\n pop a: add a to the value in register 0 (equivalent to ╜+╗)", "╕╕\nreg1_add\n pop a: add a to the value in register 1 (equivalent to ╛+╝)", "╣╣\npascal_row\n pop a: push the ath row in Pascal's triangle", "║║\nmiddle\n pop [a] or \"a\": push median([a]/\"a\") (using ordinals if string)", "╗╗\nreg0_save\n pop a: save a in register 0", "╝╝\nreg1_save\n pop a: save a in register 1", "╜╜\nreg0_load\n push the value in register 0 (initially a 0)", "╛╛\nreg1_load\n push the value in register 1 (initially the empty string)", "┐┐\nregn_save\n pop a,b: push b to register a", "└└\nregn_load\n pop a: push the value in register a", "┴┴\nSYNTAX\n pop f,[a]: push cumulative reduce of f over [a]", "┬┬\ntranspose\n pop a: push transpose(a) ([[1,2,3],[4,5,6]] -> [[1,4],[2,5],[3,6]])", "├├\nbin\n pop a: push big-endian binary representation of a (bin(a) for ints, binary float data for floats, ascii_to_bin(a) for strings)", "──\nhex\n pop a: push big-endian hexadecimal representation of a (same as 0xC3 but with hex)", "┼┼\nstack_dup_each\n duplicate each element on stack ([a,b,c] => [a,a,b,b,c,c])", "╞╞\nstack_dup_each_n\n pop a: make a total copies of each element on stack (3 [a,b,c] -> [a,a,a,b,b,b,c,c,c])", "╟╟\nnest_n\n pop a: pop a elements and push a list containing those elements in their original order", "╚╚\nshuffle\n pop [a]: push random.shuffle(a)", "╔╔\nuniquify\n pop \"a\" or [a]: push uniquify(a)", "╩╩\nreg_input\n read all input and push each to its own numbered register, starting with 0", "╦╦\npi\n push pi", "╠╠\ne\n push e", "══\nis_unique\n pop \"a\" or [a], push 1 if all elements are unique else 0", "╬╬\nwhile_call\n pop f: while value on top of stack is truthy (peek), call f", "╧╧\ncombinations\n pop [a] or \"a\",b: push all b-length combinations of a", "╨╨\npermutations\n pop [a] or \"a\",b: push all b-length permutations of a", "╤╤\npow10\n pop a: push 10**a", "╥╥\nlog10 log\n pop a: push log(a) (log base 10)", "╙╙\npow2\n pop a: push 2**a", "╘╘\nlog2 lg\n pop a: push lg(a) (log base 2)", "╒╒\nln2\n push ln(2)", "╓╓\nfirst_n_truthy\n pop f,n: push first n values where f(x) is truthy, starting with f(0) (the function is called each time with a stack only containing n)", "╫╫\nre_im\n pop a: push Re(a), Im(a) (real and imaginary parts of a)", "╪╪\nchunk_length\n pop [a],b: push a list containing each non-overlapping b-length sublist of [a] (chunk by length)", "┘┘\nord_cp437\n pop a: push ord_cp437(a)", "┌┌\nchr_cp437\n pop a: push chr_cp437(a)", "██\nnCr\n pop a,b: push C(a,b) (aCb)", "▄▄\nnPr\n pop a,b: push P(a,b) (aPb)", "▌▌\nb64decode\n pop \"a\": push b64decode(\"a\")", "▐▐\nb64encode\n pop \"a\": push b64encode(\"a\")", "▀▀\nbase_digits\n pop a: push digits in base a", "αα\nrepeat_each\n pop a,[b]: push a list containing all the elements of [b] repeated a times; pop a,b: push a list containing a copies of b", "ßß\nnth_input\n pop a: push the ath input value (defaults to 0 if a is not an integer or is >= the number of inputs currently read (without consuming a), or if the stack is empty)", "ΓΓ\ngamma\n pop a: push Gamma(a)", "ππ\nproduct\n pop [a]: push product([a])", "ΣΣ\nsum\n pop [a]: push sum([a])", "σσ\ncumulative_sums\n pop [a]: push cumulative sums of [a]", "µµ\nrms\n pop [a]: push rms (root-mean-square) of [a]", "ττ\ndouble\n pop a: push 2*a", "ΦΦ\nslice\n pop [a],b,c,d: push a[b:c:d]; pop [a],[b]: push a[b[0]:b[1]:b[2]] (list slicing)", "δδ\ndig\n pop a: bring the (a mod len(stack))'th item on the stack to the top", "∞∞\ntoggle_preserve preserve_on preserve_off\n toggle preserve mode; if on, stack items are peeked rather than popped; implicitly turned off at EOF", "φφ\nphi\n push phi (golden ratio)", "εε\nempty_string\n push \"\" (empty string)", "∩∩\nintersection\n pop [a],[b]: push intersection of [a] and [b]", "≡≡\neval\n pop a: push eval(a) (Python-style evaluation)", "±±\nunary_negate swap_quotes\n pop a: push -a (unary negate); pop \"a\": push \"a\" with all single-quotes replaced with double quotes and vice-versa", "≥≥\ngte\n pop a,b: push a>=b", "≤≤\nlte\n pop a,b: push a<=b", "⌠⌠\nfunc_begin\n begin function literal", "⌡⌡\nfunc_end\n end function literal", "÷÷\ndivisors\n pop a: push a list of all positive divisors of a that are less than or equal to a", "≈≈\nint\n pop a: push int(a)", "°°\nradians\n pop a: push radians(a)", "∙∙\ncartesian_product cartesian_power\n pop [a],[b]: push Cartesian product of [a] and [b]; pop [a],b: push [a]^b (Cartesian product of b copies of [a])", "√√\nsqrt\n pop a: push sqrt(a)", "ⁿⁿ\npow\n pop a,b: push pow(a,b)", "²²\nsquare\n pop a: push a*a", "■■\nwrite_all_safe\n print the entire stack without popping, separated by spaces"] + , bqk = ''.replace(/∙/g, '') + , bqv = ''.replace(/∙/g, '') + , tc = {}, bqc = {} //tab completions and ` completions + for (let i = 0; i < bqk.length; i++)bqc[bqk[i]] = bqv[i] + for (let i = 0; i < tcs.length; i += 3)tc[tcs[i] + tcs[i + 1]] = tcs[i + 2] + for (let i = 0; i < tcs.length; i += 3) { let k = tcs[i + 1] + tcs[i]; tc[k] = tc[k] || tcs[i + 2] } + let lbh = ''; for (let i = 0; i < lbs.length; i++) { + let ks = [] + for (let j = 0; j < tcs.length; j += 3)if (lbs[i][0] === tcs[j + 2]) ks.push('\n' + tcs[j] + ' ' + tcs[j + 1] + ' ') + for (let j = 0; j < bqk.length; j++)if (lbs[i][0] === bqv[j]) ks.push('\n` ' + bqk[j]) + lbh += '' + lbs[i][0] + '' + } + let d = document, el = d.createElement('div'); el.innerHTML = + `
${lbh}
+ ` -d.body.appendChild(el) -let t,ts=[],lb=el.firstChild,bqm=0 //t:textarea or input, lb:language bar, bqm:backquote mode -let pd=x=>x.preventDefault() -let ev=(x,t,f,c)=>x.addEventListener(t,f,c) -ev(lb,'mousedown',x=>{ - if(x.target.classList.contains('ngn_x')){lb.hidden=1;upd();pd(x);return} - if(x.target.nodeName==='B'&&t){ - let i=t.selectionStart,j=t.selectionEnd,v=t.value,s=x.target.textContent - if(i!=null&&j!=null){t.value=v.slice(0,i)+s+v.slice(j);t.selectionStart=t.selectionEnd=i+s.length} - pd(x);return - } -}) -let fk=x=>{ - let t=x.target - if(bqm){let i=t.selectionStart,v=t.value,c=bqc[x.key];if(x.which>31){bqm=0;d.body.classList.remove('ngn_bq')} - if(c){t.value=v.slice(0,i)+c+v.slice(i);t.selectionStart=t.selectionEnd=i+1;pd(x);return!1}} - switch(x.ctrlKey+2*x.shiftKey+4*x.altKey+8*x.metaKey+100*x.which){ - case 900:{let i=t.selectionStart,v=t.value,c=tc[v.slice(i-2,i)] //tab - if(c){t.value=v.slice(0,i-2)+c+v.slice(i);t.selectionStart=t.selectionEnd=i-1;pd(x)} - break} - } -} -let ff=x=>{ - let t0=x.target,nn=t0.nodeName.toLowerCase() - if(nn!=='textarea'&&(nn!=='input'||t0.type!=='text'&&t0.type!=='search'))return - t=t0;if(!t.ngn){t.ngn=1;ts.push(t);ev(t,'keydown',fk)} -} -let upd=_=>{d.body.style.marginTop=lb.clientHeight+'px'} -upd();ev(window,'resize',upd) -ev(d,'focus',ff,!0);let ae=d.activeElement;ae&&ff({type:'focus',target:ae}) + d.body.appendChild(el) + let t, ts = [], lb = el.firstChild, bqm = 0 //t:textarea or input, lb:language bar, bqm:backquote mode + let pd = x => x.preventDefault() + let ev = (x, t, f, c) => x.addEventListener(t, f, c) + ev(lb, 'mousedown', x => { + if (x.target.classList.contains('ngn_x')) { lb.hidden = 1; upd(); pd(x); return } + if (x.target.nodeName === 'B' && t) { + let i = t.selectionStart, j = t.selectionEnd, v = t.value, s = x.target.textContent + if (i != null && j != null) { t.value = v.slice(0, i) + s + v.slice(j); t.selectionStart = t.selectionEnd = i + s.length } + pd(x); return + } + }) + let fk = x => { + let t = x.target + if (bqm) { + let i = t.selectionStart, v = t.value, c = bqc[x.key]; if (x.which > 31) { bqm = 0; d.body.classList.remove('ngn_bq') } + if (c) { t.value = v.slice(0, i) + c + v.slice(i); t.selectionStart = t.selectionEnd = i + 1; pd(x); return !1 } + } + switch (x.ctrlKey + 2 * x.shiftKey + 4 * x.altKey + 8 * x.metaKey + 100 * x.which) { + case 900: { + let i = t.selectionStart, v = t.value, c = tc[v.slice(i - 2, i)] //tab + if (c) { t.value = v.slice(0, i - 2) + c + v.slice(i); t.selectionStart = t.selectionEnd = i - 1; pd(x) } + break + } + } + } + let ff = x => { + let t0 = x.target, nn = t0.nodeName.toLowerCase() + if (nn !== 'textarea' && (nn !== 'input' || t0.type !== 'text' && t0.type !== 'search')) return + t = t0; if (!t.ngn) { t.ngn = 1; ts.push(t); ev(t, 'keydown', fk) } + } + let upd = _ => { d.body.style.marginTop = lb.clientHeight + 'px' } + upd(); ev(window, 'resize', upd) + ev(d, 'focus', ff, !0); let ae = d.activeElement; ae && ff({ type: 'focus', target: ae }) })(); diff --git a/apl.html b/apl.html index 41f67b5..44df430 100644 --- a/apl.html +++ b/apl.html @@ -1,40 +1,59 @@ - - APL - - - -
-

APL language bar, key-bindings, and character compositions

-

This provides three ways to easily enter APL characters into pretty much any input field on any webpage:

-
    -
  1. Use backtick ` as prefix APL key, e.g. `a gives .
  2. -
  3. Enter a combo sequence and hit Tab, e.g. aaTab gives .
  4. -
  5. Click on symbols in the language bar.
  6. -
-

Try it here:

-

Hover over a symbol in the language bar for keybindings and combo sequences.

-

Installation

-

Desktop browser

-
    -
  1. Drag this link to your bookmarks bar: APL
  2. -
-

Mobile browser

-
    -
  1. Add a bookmark for this page.
  2. -
  3. Edit the bookmark's target URL address to javascript:(d=>{let%20e=d.createElement("script");e.src="https://abrudz.github.io/lb/lb.js";d.body.appendChild(e)})(document)
  4. -
-

Webpage

-
    -
  1. Include this HTML in your page: <script src="https://abrudz.github.io/lb/lb.js"></script>
  2. -
-

Activation

-
    -
  1. Navigate to the web page where you want to enter APL characters.
  2. -
  3. Click on the APL bookmark. The language bar should appear at the web page's top.
  4. -
-
- - - + + + + APL + + + + +
+

APL language bar, key-bindings, and character compositions

+

This provides three ways to easily enter APL characters into pretty much any input field on any webpage:

+
    +
  1. Use backtick ` as prefix APL key, e.g. `a gives .
  2. +
  3. Enter a combo sequence and hit Tab, e.g. aaTab gives . +
  4. +
  5. Click on symbols in the language bar.
  6. +
+

Try it here:

+

Hover over a symbol in the language bar for keybindings and combo sequences.

+

Installation

+

Desktop browser

+
    +
  1. Drag this link to your bookmarks bar: APL +
  2. +
+

Mobile browser

+
    +
  1. Add a bookmark for this page.
  2. +
  3. Edit the bookmark's target URL address to + javascript:(d=>{let%20e=d.createElement("script");e.src="https://abrudz.github.io/lb/lb.js";d.body.appendChild(e)})(document) +
  4. +
+

Webpage

+
    +
  1. Include this HTML in your page: + <script src="https://abrudz.github.io/lb/lb.js"></script>
  2. +
+

Activation

+
    +
  1. Navigate to the web page where you want to enter APL characters.
  2. +
  3. Click on the APL bookmark. The language bar should appear at the web page's top.
  4. +
+
+ + + + \ No newline at end of file diff --git a/bqn.html b/bqn.html new file mode 100644 index 0000000..fffd1b2 --- /dev/null +++ b/bqn.html @@ -0,0 +1,59 @@ + + + + + + BQN + + + + +
+

+ BQN language bar, key-bindings, and character compositions + +

+

This provides two ways to easily enter BQN characters into pretty much any input field on any webpage:

+
    +
  1. Use backslash \ as prefix BQN key, e.g. \G gives 𝔾.
  2. +
  3. Click on symbols in the language bar.
  4. +
+

Try it here:

+

Hover over a symbol in the language bar for keybindings.

+

Installation

+

Desktop browser

+
    +
  1. Drag this link to your bookmarks bar: BQN +
  2. +
+

Mobile browser

+
    +
  1. Add a bookmark for this page.
  2. +
  3. Edit the bookmark's target URL address to + javascript:(d=>{let%20e=d.createElement("script");e.src="https://abrudz.github.io/lb/bqn.js";d.body.appendChild(e)})(document) +
  4. +
+

Webpage

+
    +
  1. Include this HTML in your page: + <script src="https://abrudz.github.io/lb/bqn.js"></script>
  2. +
+

Activation

+
    +
  1. Navigate to the web page where you want to enter BQN characters.
  2. +
  3. Click on the BQN bookmark. The language bar should appear at the web page's top.
  4. +
+
+ + + + \ No newline at end of file diff --git a/bqn.js b/bqn.js new file mode 100644 index 0000000..96cec6e --- /dev/null +++ b/bqn.js @@ -0,0 +1,64 @@ +; (_ => { + let hc = { '<': '<', '&': '&', "'": ''', '"': '"' }, he = x => x.replace(/[<&'"]/g, c => hc[c]) //html chars and escape fn + , tcs = '' + , lbs = ['+Conjugate\nAdd', '-Negate\nSubtract', '×Sign\nMultiply', '÷Reciprocal\nDivide', '⋆Exponential\nPower', '√Square Root\nRoot', '⌊Floor\nMinimum', '⌈Ceiling\nMaximum', '∧Sort Up\nAnd', '∨Sort Down\nOr', '¬Not\nSpan', '|Absolute Value\nModulus', '≤Less Than or Equal to', 'Merge\nGreater Than', '≥Greater Than or Equal to', '=Rank\nEquals', '≠Length\nNot Equals', '≡Depth\nMatch', '≢Shape\nNot Match', '⊣Identity\nLeft', '⊢Identity\nRight', '⥊Deshape\nReshape', '∾Join\nJoin to', '≍Solo\nCouple', '↑Prefixes\nTake', '↓Suffixes\nDrop', '↕Range\nWindows', '«Shift Before', '»Shift After', '⌽Reverse\nRotate', '⍉Transpose\nReorder axes', '/Indices\nReplicate', '⍋Grade Up\nBins Up', '⍒Grade Down\nBins Down', '⊏First Cell\nSelect', '⊑First\nPick', '⊐Index of', '⊒Occurrence Count\nProgressive Index of', '∊Unique Mask\nMember of', '⍷Deduplicate\nFind', '⊔Group Indices\nGroup', '!Assert\nAssert with message', ' ', '˙Constant', '˜Self/Swap', '∘Atop', '○Over', '⊸Before/Bind', '⟜After/Bind', '⌾Under', '⊘Valences', '◶Choose', '⎉Rank', '˘Cells', '⚇Depth', '¨Each', '⌜Table', '⍟Repeat', '⁼Undo', '´Fold', '˝Insert', '`Scan', ' ', '←Define', '⇐Export', '↩Change', '→Return', '⋄Separator', ',Separator', '(Begin expression', ')End expression', '{Begin block', '}End block', '⟨Begin list', '⟩End list', '‿Strand', ' ', '·Nothing', '•System', '𝕨Left argument', '𝕎Left argument (as function)', '𝕩Right argument', '𝕏Right argument (as function)', '𝕗Modifier left operand (as subject)', '𝔽Modifier left operand', '𝕘2-modifier right operand (as subject)', '𝔾2-modifier right operand', '𝕤Current function (as subject)', '𝕊Current function', '𝕣Current modifier', ' ', '¯Minus', 'πPi', '∞Infinity', '@Null character', '#Comment'] + , bqk = Array.from('`123456890-=~!@#$%^&*()_+qwertuiop[]QWERTIOP{}asdfghjkl;ASFGHKL:"zxcvbm,./XVBM<>? \'') + , bqv = Array.from('˜˘¨⁼⌜´˝∞¯•÷׬⎉⚇⍟◶⊘⎊⍎⍕⟨⟩√⋆⌽𝕨∊↑∧⊔⊏⊐π←→↙𝕎⍷𝕣⍋⊑⊒⍳⊣⊢⍉𝕤↕𝕗𝕘⊸∘○⟜⋄↖𝕊𝔽𝔾«⌾»·˙⥊𝕩↓∨⌊≡∾≍≠𝕏⍒⌈≢≤≥⇐‿↩') + , tc = {}, bqc = {} //tab completions and ` completions + for (let i = 0; i < bqk.length; i++)bqc[bqk[i]] = bqv[i] + for (let i = 0; i < tcs.length; i += 3)tc[tcs[i] + tcs[i + 1]] = tcs[i + 2] + for (let i = 0; i < tcs.length; i += 3) { let k = tcs[i + 1] + tcs[i]; tc[k] = tc[k] || tcs[i + 2] } + let lbh = ''; for (let i = 0; i < lbs.length; i++) { + let [k, ...v] = [...lbs[i]]; v = v.join(''); + let ks = [] + for (let j = 0; j < tcs.length; j += 3)if (k === tcs[j + 2]) ks.push('\n' + tcs[j] + ' ' + tcs[j + 1] + ' ') + for (let j = 0; j < bqk.length; j++)if (k === bqv[j]) ks.push('\n` ' + bqk[j]) + lbh += '' + k + '' + } + let d = document, el = d.createElement('div'); el.innerHTML = + `
${lbh}
+ + ` + d.body.appendChild(el) + let t, ts = [], lb = el.firstChild, bqm = 0 //t:textarea or input, lb:language bar, bqm:backquote mode + let pd = x => x.preventDefault() + let ev = (x, t, f, c) => x.addEventListener(t, f, c) + ev(lb, 'mousedown', x => { + if (x.target.classList.contains('ngn_x')) { lb.hidden = 1; upd(); pd(x); return } + if (x.target.nodeName === 'B' && t) { + let i = t.selectionStart, j = t.selectionEnd, v = t.value, s = x.target.textContent + if (i != null && j != null) { t.value = v.slice(0, i) + s + v.slice(j); t.selectionStart = t.selectionEnd = i + s.length } + pd(x); return + } + }) + let fk = x => { + let t = x.target + if (bqm) { + let i = t.selectionStart, v = t.value, c = bqc[x.key]; if (x.which > 31) { bqm = 0; d.body.classList.remove('ngn_bq') } + if (c) { t.value = v.slice(0, i) + c + v.slice(i); t.selectionStart = t.selectionEnd = i + c.length; pd(x); return !1 } + } + else if (!x.ctrlKey && !x.shiftKey && !x.altKey && !x.metaKey) { + if ("\\½²^º§ùµ°".indexOf(x.key) > -1) { + bqm = 1; d.body.classList.add('ngn_bq'); pd(x); // ` or other trigger symbol pressed, wait for next key + } else if (x.key == "Tab") { + let i = t.selectionStart, v = t.value, c = tc[v.slice(i - 2, i)] + if (c) { t.value = v.slice(0, i - 2) + c + v.slice(i); t.selectionStart = t.selectionEnd = i - 1; pd(x) } + } + } + } + let ff = x => { + let t0 = x.target, nn = t0.nodeName.toLowerCase() + if (nn !== 'textarea' && (nn !== 'input' || t0.type !== 'text' && t0.type !== 'search')) return + t = t0; if (!t.ngn) { t.ngn = 1; ts.push(t); ev(t, 'keydown', fk) } + } + let upd = _ => { d.body.style.marginTop = lb.clientHeight + 'px' } + upd(); ev(window, 'resize', upd) + ev(d, 'focus', ff, !0); let ae = d.activeElement; ae && ff({ type: 'focus', target: ae }) +})(); diff --git a/brachylog.js b/brachylog.js index b94edfe..8421db2 100644 --- a/brachylog.js +++ b/brachylog.js @@ -1,22 +1,22 @@ -;(_=>{ -let hc={'<':'<','&':'&',"'":''','"':'"'},he=x=>x.replace(/[<&'"]/g,c=>hc[c]) //html chars and escape fn -,tcs="/\\∧\\/∨<=≤>=≥E(∈E)∋(=⊆)=⊇_|⊥<>↔<^↖(<⟨)>⟩<|↰o<↺o>↻v|√|^⌉|_⌋[[⟦]]⟧|Nℕ|Zℤ|Rℝ","?","@","A","B","C","D","E","F","G","H","I","J","K","L","M","N","O","P","Q","R","S","T","U","V","W","X","Y","Z","[","\\","]","^","_","`","a","b","c","d","e","f","g","h","i","j","k","l","m","n","o","p","q","r","s","t","u","v","w","x","y","z","{","\|","}","~","₀","₁","₂","₃","₄","₅","₆","₇","₈","₉","⁰","¹","²","³","⁴","⁵","⁶","⁷","⁸","⁹","ᵃ","ᵇ","ᶜ","ᵈ","ᵉ","ᶠ","ᵍ","ʰ","ⁱ","ʲ","ᵏ","ˡ","ᵐ","ⁿ","ᵒ","ᵖ","ʳ","ˢ","ᵗ","ᵘ","ᵛ","ʷ","ˣ","ʸ","ᶻ","₍","₎","⁽","⁾","ạ","ḅ","ḍ","ẹ","ḥ","ị","ḳ","ḷ","ṃ","ṇ","ọ","ṛ","ṣ","ṭ","ụ","ṿ","ẉ","ỵ","ẓ","ȧ","ḃ","ċ","ḋ","ė","ḟ","ġ","ḣ","ṁ","ṅ","ȯ","ṗ","ṙ","ṡ","ṫ","ẇ","ẋ","ẏ","ż","Ạ","Ḅ","Ḍ","Ẹ","Ḥ","Ị","Ḳ","Ḷ","Ṃ","Ṇ","Ọ","Ṛ","Ṣ","Ṭ","Ụ","Ṿ","Ẉ","Ỵ","Ẓ","Ȧ","Ḃ","Ċ","Ḋ","Ė","Ḟ","Ġ","Ḣ","İ","Ṁ","Ṅ","Ȯ","Ṗ","Ṙ","Ṡ","Ṫ","Ẇ","Ẋ","Ẏ","Ż","π","φ","≜"] -,bqk=''.replace(/∙/g,'') -,bqv=''.replace(/∙/g,'') -,tc={},bqc={} //tab completions and ` completions -for(let i=0;i') - for(let j=0;j'+lbs[i][0]+'
' -} -let d=document,el=d.createElement('div');el.innerHTML= -`
${lbh}
- +; (_ => { + let hc = { '<': '<', '&': '&', "'": ''', '"': '"' }, he = x => x.replace(/[<&'"]/g, c => hc[c]) //html chars and escape fn + , tcs = "/\\∧\\/∨<=≤>=≥E(∈E)∋(=⊆)=⊇_|⊥<>↔<^↖(<⟨)>⟩<|↰o<↺o>↻v|√|^⌉|_⌋[[⟦]]⟧|Nℕ|Zℤ|Rℝ", "?", "@", "A", "B", "C", "D", "E", "F", "G", "H", "I", "J", "K", "L", "M", "N", "O", "P", "Q", "R", "S", "T", "U", "V", "W", "X", "Y", "Z", "[", "\\", "]", "^", "_", "`", "a", "b", "c", "d", "e", "f", "g", "h", "i", "j", "k", "l", "m", "n", "o", "p", "q", "r", "s", "t", "u", "v", "w", "x", "y", "z", "{", "\|", "}", "~", "₀", "₁", "₂", "₃", "₄", "₅", "₆", "₇", "₈", "₉", "⁰", "¹", "²", "³", "⁴", "⁵", "⁶", "⁷", "⁸", "⁹", "ᵃ", "ᵇ", "ᶜ", "ᵈ", "ᵉ", "ᶠ", "ᵍ", "ʰ", "ⁱ", "ʲ", "ᵏ", "ˡ", "ᵐ", "ⁿ", "ᵒ", "ᵖ", "ʳ", "ˢ", "ᵗ", "ᵘ", "ᵛ", "ʷ", "ˣ", "ʸ", "ᶻ", "₍", "₎", "⁽", "⁾", "ạ", "ḅ", "ḍ", "ẹ", "ḥ", "ị", "ḳ", "ḷ", "ṃ", "ṇ", "ọ", "ṛ", "ṣ", "ṭ", "ụ", "ṿ", "ẉ", "ỵ", "ẓ", "ȧ", "ḃ", "ċ", "ḋ", "ė", "ḟ", "ġ", "ḣ", "ṁ", "ṅ", "ȯ", "ṗ", "ṙ", "ṡ", "ṫ", "ẇ", "ẋ", "ẏ", "ż", "Ạ", "Ḅ", "Ḍ", "Ẹ", "Ḥ", "Ị", "Ḳ", "Ḷ", "Ṃ", "Ṇ", "Ọ", "Ṛ", "Ṣ", "Ṭ", "Ụ", "Ṿ", "Ẉ", "Ỵ", "Ẓ", "Ȧ", "Ḃ", "Ċ", "Ḋ", "Ė", "Ḟ", "Ġ", "Ḣ", "İ", "Ṁ", "Ṅ", "Ȯ", "Ṗ", "Ṙ", "Ṡ", "Ṫ", "Ẇ", "Ẋ", "Ẏ", "Ż", "π", "φ", "≜"] + , bqk = ''.replace(/∙/g, '') + , bqv = ''.replace(/∙/g, '') + , tc = {}, bqc = {} //tab completions and ` completions + for (let i = 0; i < bqk.length; i++)bqc[bqk[i]] = bqv[i] + for (let i = 0; i < tcs.length; i += 3)tc[tcs[i] + tcs[i + 1]] = tcs[i + 2] + for (let i = 0; i < tcs.length; i += 3) { let k = tcs[i + 1] + tcs[i]; tc[k] = tc[k] || tcs[i + 2] } + let lbh = ''; for (let i = 0; i < lbs.length; i++) { + let ks = [] + for (let j = 0; j < tcs.length; j += 3)if (lbs[i][0] === tcs[j + 2]) ks.push('\n' + tcs[j] + ' ' + tcs[j + 1] + ' ') + for (let j = 0; j < bqk.length; j++)if (lbs[i][0] === bqv[j]) ks.push('\n` ' + bqk[j]) + lbh += '' + lbs[i][0] + '' + } + let d = document, el = d.createElement('div'); el.innerHTML = + `
${lbh}
+ ` -d.body.appendChild(el) -let t,ts=[],lb=el.firstChild,bqm=0 //t:textarea or input, lb:language bar, bqm:backquote mode -let pd=x=>x.preventDefault() -let ev=(x,t,f,c)=>x.addEventListener(t,f,c) -ev(lb,'mousedown',x=>{ - if(x.target.classList.contains('ngn_x')){lb.hidden=1;upd();pd(x);return} - if(x.target.nodeName==='B'&&t){ - let i=t.selectionStart,j=t.selectionEnd,v=t.value,s=x.target.textContent - if(i!=null&&j!=null){t.value=v.slice(0,i)+s+v.slice(j);t.selectionStart=t.selectionEnd=i+s.length} - pd(x);return - } -}) -let fk=x=>{ - let t=x.target - if(bqm){let i=t.selectionStart,v=t.value,c=bqc[x.key];if(x.which>31){bqm=0;d.body.classList.remove('ngn_bq')} - if(c){t.value=v.slice(0,i)+c+v.slice(i);t.selectionStart=t.selectionEnd=i+1;pd(x);return!1}} - switch(x.ctrlKey+2*x.shiftKey+4*x.altKey+8*x.metaKey+100*x.which){ - case 900:{let i=t.selectionStart,v=t.value,c=tc[v.slice(i-2,i)] //tab - if(c){t.value=v.slice(0,i-2)+c+v.slice(i);t.selectionStart=t.selectionEnd=i-1;pd(x)} - break} - } -} -let ff=x=>{ - let t0=x.target,nn=t0.nodeName.toLowerCase() - if(nn!=='textarea'&&(nn!=='input'||t0.type!=='text'&&t0.type!=='search'))return - t=t0;if(!t.ngn){t.ngn=1;ts.push(t);ev(t,'keydown',fk)} -} -let upd=_=>{d.body.style.marginTop=lb.clientHeight+'px'} -upd();ev(window,'resize',upd) -ev(d,'focus',ff,!0);let ae=d.activeElement;ae&&ff({type:'focus',target:ae}) + d.body.appendChild(el) + let t, ts = [], lb = el.firstChild, bqm = 0 //t:textarea or input, lb:language bar, bqm:backquote mode + let pd = x => x.preventDefault() + let ev = (x, t, f, c) => x.addEventListener(t, f, c) + ev(lb, 'mousedown', x => { + if (x.target.classList.contains('ngn_x')) { lb.hidden = 1; upd(); pd(x); return } + if (x.target.nodeName === 'B' && t) { + let i = t.selectionStart, j = t.selectionEnd, v = t.value, s = x.target.textContent + if (i != null && j != null) { t.value = v.slice(0, i) + s + v.slice(j); t.selectionStart = t.selectionEnd = i + s.length } + pd(x); return + } + }) + let fk = x => { + let t = x.target + if (bqm) { + let i = t.selectionStart, v = t.value, c = bqc[x.key]; if (x.which > 31) { bqm = 0; d.body.classList.remove('ngn_bq') } + if (c) { t.value = v.slice(0, i) + c + v.slice(i); t.selectionStart = t.selectionEnd = i + 1; pd(x); return !1 } + } + switch (x.ctrlKey + 2 * x.shiftKey + 4 * x.altKey + 8 * x.metaKey + 100 * x.which) { + case 900: { + let i = t.selectionStart, v = t.value, c = tc[v.slice(i - 2, i)] //tab + if (c) { t.value = v.slice(0, i - 2) + c + v.slice(i); t.selectionStart = t.selectionEnd = i - 1; pd(x) } + break + } + } + } + let ff = x => { + let t0 = x.target, nn = t0.nodeName.toLowerCase() + if (nn !== 'textarea' && (nn !== 'input' || t0.type !== 'text' && t0.type !== 'search')) return + t = t0; if (!t.ngn) { t.ngn = 1; ts.push(t); ev(t, 'keydown', fk) } + } + let upd = _ => { d.body.style.marginTop = lb.clientHeight + 'px' } + upd(); ev(window, 'resize', upd) + ev(d, 'focus', ff, !0); let ae = d.activeElement; ae && ff({ type: 'focus', target: ae }) })(); diff --git a/husk.js b/husk.js index 47a6c8f..e545acf 100644 --- a/husk.js +++ b/husk.js @@ -1,22 +1,22 @@ -;(_=>{ -let hc={'<':'<','&':'&',"'":''','"':'"'},he=x=>x.replace(/[<&'"]/g,c=>hc[c]) //html chars and escape fn -,tcs="cur¤hlf½ud.↕up.↑dow↓lr.↔lft←rgt→bar¦exc¡dex‼ell…ppm‰dag†ddg‡srd√leq≤geq≥pm.±ptl∂int∫inf∞apx≈neq≠cng≡neg¬div÷eks×blt·nul₀one₁two₂thr₃fou₄fiv₅six₆sev₇eig₈nin₉lce⌈rce⌉lfl⌊rfl⌋GamΓTheΘLamΛXi.ΞPi.ΠSigΣPsiΨOhmΩdelδepsεetaηlamλmu.μxi.ξpi.πsjgσphiφchiχpsiψohmωNul⁰One¹Two²Thr³Fou⁴Fiv⁵Six⁶Sev⁷Eig⁸Nin⁹cnt¢gbp£eur€yen¥fl.ƒacu´top▲bot▼est►wst◄sec§dC.ĊdD.ḊdF.ḞdG.ĠdI.İdM.ṀdP.ṖdR.ṘdS.ṠdT.ṪdX.Ẋdd.ḋde.ėdf.ḟdg.ġdh.ḣdl.ŀdm.ṁdo.ȯdp.ṗdr.ṙds.ṡdt.ṫdz.żdie¨DE.ËDO.ÖDe.ëDo.öDu.üso.øsqu□pgf¶ll.«rr.»" -,lbs=["¤¤\ncombin \n(y -> y -> z) -> (x -> y) -> x -> x -> z \nCompose both arguments of binary function","½½\nhalve \nTNum -> TNum \nDivide by 2","↕↕\nspan \n(Concrete y) => (x -> y) -> [x] -> ([x], [x]) \nSplit at first value where function gives falsy result","↑↑\ntake \nTNum -> [x] -> [x] \nTake n elements from list. Negative n takes from the end","↓↓\ndrop \nTNum -> [x] -> [x] \nDrop n elements from list. Negative n drops from the end","↔↔\nswap \n(x, y) -> (y, x) \nSwap a pair","←←\nhead \n[x] -> x \nFirst value of a list","→→\nlast \n[x] -> x \nLast value of a list","\\\\\nNewline \n\nSeparates lines in program","¦¦\ndivds \nTNum -> TNum -> TNum \n1 if b == 0, b / a if a divides b, 0 otherwise","¡¡\niter \n(x -> x) -> x -> [x] \nApply function repeatedly, collect values in infinite list","‼‼\ntwice \n(x -> x) -> (x -> x) \nApply function twice","……\nrangeN \nTNum -> TNum -> [TNum] \nInclusive numeric range","‰‰\ndivmod \nTNum -> TNum -> [TNum] \nTwo-element list [b ÷ a, b % a]","††\nvec \n(Vect a b x y) => (a -> b) -> x -> y \nVectorize a function (\"deep map\")","‡‡\nvec2 \n(Vect2 a b c x y z) => (a -> b -> c) -> x -> y -> z \nBi-vectorize a function (\"deep zip\")","√√\nsqrt \nTNum -> TNum \nSquare root","≤≤\nle \n(Concrete x) => x -> x -> TNum \nLess than or equal","≥≥\nge \n(Concrete x) => x -> x -> TNum \nGreater than or equal","±±\nsign \nTNum -> TNum \nSign of a number","∂∂\nadiags \n[[x]] -> [[x]] \nAntidiagonals","∫∫\ncumsum \n[TNum] -> [TNum] \nCumulative sum","∞∞\nrep \nx -> [x] \nInfinite list of copies of the argument","≈≈\nsimil \n(Concrete x) => x -> x -> TNum \nSimilar. For numbers or chars checks if the absolute difference is <=1. For lists checks if they are the same length. For Pairs checks if both elements are similar.","≠≠\nneq \n(Concrete x) => x -> x -> TNum \nNot equal","≡≡\ncongr \n(Concrete x) => x -> x -> TNum \nRecursively check if the two arguments have the same shape and the same distribution of truthy/falsy values. Returns 1 or 0.","¬¬\nnot \n(Concrete x) => x -> TNum \nNegation of truthiness","÷÷\nidiv \nTNum -> TNum -> TNum \nInteger division","××\nmix \n(x -> y -> z) -> [x] -> [y] -> [z] \nFunction applied to all pairs drawn from the lists","!!\nindex \nTNum -> [x] -> x \nValue at modular index","\\\\\ninv \nTNum -> TNum \nReciprocal number","\"\"\nDouble quote \n\nString delimiter","##\ncountf \n(Concrete y) => (x -> y) -> [x] -> TNum \nNumber of list elems where function result is truthy","%%\nmod \nTNum -> TNum -> TNum \nModulus of second argument by first","&&\nand \n(Concrete x) => x -> x -> x \nSecond argument if falsy, else first","''\nSingle quote \n\nCharacter delimiter","((\nParentheses \n\nGroup expressions","**\nmul \nTNum -> TNum -> TNum \nMultiply numbers","++\nadd \nTNum -> TNum -> TNum \nAdd numbers",",,\npair \nx -> y -> (x, y) \nConstruct pair","--\nsub \nTNum -> TNum -> TNum \nSubtract first argument from second","..\nDecimal point \n\nUsed in floating point literals","//\ndiv \nTNum -> TNum -> TNum \nExact division, uses rational numbers when possible","::\ncons \nx -> [x] -> [x] \nPrepend a value to a list",";;\npure \nx -> [x] \nCreate singleton list","<<\nlt \n(Concrete x) => x -> x -> TNum \nLess than","==\neq \n(Concrete x) => x -> x -> TNum \nEquals",">>\ngt \n(Concrete x) => x -> x -> TNum \nGreater than","??\nif \n(Concrete x) => y -> y -> x -> y \nTernary if conditioned on third argument","AA\nmean \n[TNum] -> TNum \nAverage of a list","BB\nbase \nTNum -> TNum -> [TNum] \nDigits in given base","CC\ncut \nTNum -> [a] -> [[a]] \nCut into sublists of given length. Negative n counts lengths from the end.","DD\ndouble \nTNum -> TNum \nMultiply by 2","EE\nsame \nConcrete x => [x] -> TNum \nLength plus 1 if all elements are equal, else 0","FF\nfoldl \n(y -> x -> y) -> y -> [x] -> y \nLeft fold","GG\nscanl \n(y -> x -> y) -> y -> [x] -> [y] \nScan from left","II\nid \nx -> x \nIdentity function","JJ\njoin \n[x] -> [[x]] -> [x] \nJoin by a list","KK\nconst \nx -> y -> x \nConstant function","LL\nlen \n[x] -> TNum \nLength of list","MM\nlmap \n(x -> y -> z) -> [x] -> y -> [z] \nMap over left argument","NN\nnats \n[TNum] \nInfinite list of natural numbers","OO\nsort \n(Concrete x) => [x] -> [x] \nSort list in ascending order","PP\nperms \n[a] -> [[a]] \nList of all permutations of the given list","QQ\nslices \n[a] -> [[a]] \nAll contiguous sublists","RR\nreplic \nTInt -> a -> [a] \nList composed by a given number of copies of a value","SS\nhook \n(x -> y -> z) -> (x -> y) -> x -> z \nS-combinator","TT\ntrsp \n[[a]] -> [[a]] \nTranspose a 2-d list, elements missing from shorter rows are skipped","UU\nnubw \nConcrete a => [a] -> [a] \nLongest prefix of a list with all unique elements","VV\nany \nConcrete b => (a->b) -> [a] -> TNum \nIndex of first element satisfying predicate, 0 if not found","WW\nwhere \nConcrete b => (a->b) -> [a] -> [TNum] \nIndices of elements satisfying predicate","XX\nslice \nTNum -> [a] -> [[a]] \nAll subslists of length n. Negative n includes final stubs.","YY\nmax \n(Concrete x) => x -> x -> x \nMaximum of two values","^^\npower \nTNum -> TNum -> TNum \nSecond argument raised to the power of the first","__\nneg \nTNum -> TNum \nNegate a number","``\nflip \n(x -> y -> z) -> y -> x -> z \nInvert order of arguments","aa\nabs \nTNum -> TNum \nAbsolute value","cc\nchr \nTNum -> TChar \nConvert integer to character","dd\nbase10 \nTNum -> [TNum] \nBase-10 digits","ee\nlist2 \nx -> x -> [x] \nCreate a list with two elements","ff\nfilter \n(Concrete y) => (x -> y) -> [x] -> [x] \nFilter list by predicate","gg\ngroup \n(Concrete x) => [x] -> [[x]] \nGroup equal adjacent values","hh\ninit \n[x] -> [x] \nRemove last element","ii\nd2i \nTDouble -> TNum \nConvert from Double to Int by rounding (round half to even)","kk\nkeyon \nConcrete y => (x -> y) -> [x] -> [[x]] \nGroup list elements into classes by function value. Classes are ordered by the function values.","mm\nmap \n(x -> y) -> [x] -> [y] \nMap function over list","nn\nbwand \nTNum -> TNum -> TNum \nBitwise AND","oo\ncom \n(y -> z) -> (x -> y) -> x -> z \nFunction composition","pp\npfac \nTNum -> [TNum] \nPrime factorization","rr\nread \n(Concrete x) => [TChar] -> x \nConvert string to value","ss\nshow \n(Concrete x) => x -> [TChar] \nConvert value to string","tt\ntail \n[x] -> [x] \nRemove first element","uu\nnub \n(Concrete x) => [x] -> [x] \nRemove duplicates","vv\nbwor \nTNum -> TNum -> TNum \nBitwise OR","ww\nwords \n[TChar] -> [[TChar]] \nSplit on spaces","xx\nsplit \nConcrete x => x -> [x] -> [[x]] \nSplit on given element","yy\nmin \n(Concrete x) => x -> x -> x \nMinimum of two values","zz\nzip \n(x -> y -> z) -> [x] -> [y] -> [z] \nZip lists with function","||\nor \n(Concrete x) => x -> x -> x \nSecond argument if truthy, else first","~~\nbranch \n(x -> y -> z) -> (u -> x) -> (v -> y) -> (u -> v -> z) \nCompose both arguments of binary function separately","··\ncomf \n(x -> y -> z) -> (u -> y) -> (x -> u -> z) \nCompose second argument of function","₀₀\nSubscript digit\n\nLine label","₁₁\nSubscript digit\n\nLine label","₂₂\nSubscript digit\n\nLine label","₃₃\nSubscript digit\n\nLine label","₄₄\nSubscript digit\n\nLine label","₅₅\nSubscript digit\n\nLine label","₆₆\nSubscript digit\n\nLine label","₇₇\nSubscript digit\n\nLine label","₈₈\nSubscript digit\n\nLine label","₉₉\nSubscript digit\n\nLine label","⌈⌈\nceil \nTNum -> TNum \nCeiling function","⌉⌉\nlcm \nTNum -> TNum -> TNum \nLowest common multiple","⌊⌊\nfloor \nTNum -> TNum \nFloor function","⌋⌋\ngcd \nTNum -> TNum -> TNum \nGreatest common divisor","ΓΓ\nlist \ny -> (x -> [x] -> y) -> [x] -> y \nPattern match on list","ΘΘ\nprep0 \n[x]->[x] \nPrepends a default value of the appropriate type to a list. Default values are either falsy values (0,[],...) or functions returning those values.","ΛΛ\nall \nConcrete b => (a->b) -> [a] -> TNum \nLength + 1 if all elements satisfy predicate, else 0","ΞΞ\nmerge \nConcrete a => [[a]] -> [a] \nMerge a list of lists. Each list should be ordered, and if there are more than 2 lists, their heads should also be ordered. Works on infinite lists.","ΠΠ\nprod \n[TNum] -> TNum \nProduct of list","ΣΣ\nsum \n[TNum] -> TNum \nSum of list","ΨΨ\ntoadjM \n(((a, a) -> c) -> [(a,a)] -> [[(a, a)]]) -> (a -> a -> c) -> [a] -> [[a]] \nApply higher-order function on adjacent pairs instead of single elements","ΩΩ\nuntil \nConcrete y => (x -> y) -> (x -> x) -> x -> x \nIterate function until test result is truthy","δδ\ndecorM \n(((a, b) -> c) -> [(a,b)] -> [[(a,d)]]) -> (a -> b -> c) -> [a] -> [b] -> [[d]] \nApply higher-order function using auxiliary list","εε\nsmall \nTNum -> TNum \nHas absolute value at most 1","ηη\nonixes \n((TNum -> a) -> [TNum] -> b) -> [a] -> b \nAct on list of indices using indexing function. If α is a function, ηα is roughly equivalent to α§!ŀ.","λλ\nSmall lambda \n\nOne-argument anonymous function","μμ\nSmall mu \n\nTwo-argument anonymous function","ξξ\nSmall xi \n\nThree-argument anonymous function","ππ\ncpow \nTNum -> [x] -> [[x]] \nCartesian power","σσ\nsubs \n(Concrete x) => [x] -> [x] -> [x] \nSubstitute list elements according to mapping. Each element is mapped to the one after its first occurrence, or itself.","φφ\nSmall phi \n\nSelf-referential anonymous function","χχ\nSmall chi \n\nSelf-referential anonymous function with 2 extra arguments","ψψ\nSmall psi \n\nSelf-referential anonymous function with extra argument","ωω\nfixp \n(Concrete x) => (x -> x) -> x -> x \nFind periodic point by iterating","⁰⁰\nSuperscript digit\n\nLambda argument","¹¹\nSuperscript digit\n\nLambda argument","²²\nSuperscript digit\n\nLambda argument","³³\nSuperscript digit\n\nLambda argument","⁴⁴\nSuperscript digit\n\nLambda argument","⁵⁵\nSuperscript digit\n\nLambda argument","⁶⁶\nSuperscript digit\n\nLambda argument","⁷⁷\nSuperscript digit\n\nLambda argument","⁸⁸\nSuperscript digit\n\nLambda argument","⁹⁹\nSuperscript digit\n\nLambda argument","¢¢\ncycle \n[x] -> [x] \nRepeat list infinitely","££\noelem \n(Concrete x) => [x] -> x -> TNum \nLike elem, but the list is supposed to be sorted","€€\nelem \n(Concrete x) => [x] -> x -> TNum \nIndex of first occurrence, or 0 if not found","¥¥\nixsof \n(Concrete x) => x -> [x] -> [TNum] \nIndices of occurrence","ƒƒ\nfix \n(x -> x) -> x \nLeast fixed point (used for recursion)","´´\nargdup \n(x -> x -> y) -> x -> y \nApply twice to same argument","▲▲\nmaxl \n(Concrete x) => [x] -> x \nMaximum of list","▼▼\nminl \n(Concrete x) => [x] -> x \nMinimum of list","►►\nmaxlby \nConcrete y => (x -> x -> y) -> [x] -> x \nMaximum element with custom ordering predicate","◄◄\nminlby \nConcrete y => (x -> x -> y) -> [x] -> x \nMinimum element with custom ordering predicate","§§\nfork \n(x -> y -> z) -> (u -> x) -> (u -> y) -> u -> z \nCompose each argument of binary function","ĊĊ\ngaps \nTNum -> [a] -> [a] \nTake every abs(n)'th element, starting from the first if n is positive, from the -n-1st if negative","ḊḊ\ndivs \nTNum -> [TNum] \nList of divisors","ḞḞ\nfoldr \n(x -> y -> y) -> y -> [x] -> y \nRight fold","ĠĠ\nscanr \n(x -> y -> y) -> y -> [x] -> [y] \nScan from right","İİ\nDotted capital I \n\nAccess built-in numeric sequences","ṀṀ\nrmap \n(x -> y -> z) -> x -> [y] -> [z] \nMap over right argument","ṖṖ\npowset \n[x] -> [[x]] \nAll finite subsequences","ṘṘ\nclone \nTNum -> [x] -> [x] \nReplicate each element by given number","ṠṠ\nhookf \n(x -> y -> z) -> (y -> x) -> y -> z \nLike S, but composes on other argument","ṪṪ\ntable \n(x -> y -> z) -> [x] -> [y] -> [[z]] \nOuter product, or \"multiplication table\"","ẊẊ\nmapad2 \n(x -> x -> y) -> [x] -> [y] \nMap over pairs of adjacent values","ḋḋ\nbase2 \nTNum -> [TNum] \nBinary digits","ėė\nlist3 \nx -> x -> x -> [x] \nCreate a list with three elements","ḟḟ\nfind \n(Concrete y) => (x -> y) -> [x] -> x \nReturn first value that gives truthy result","ġġ\ngroupOn \n(Concrete y) => (x -> y) -> [x] -> [[x]] \nGroup on function result","ḣḣ\nheads \n(Concrete x) => x -> [x] \nPrefixes for lists, range for numbers","ŀŀ\nlrange \nTNum -> [TNum] \nLowered range (from 0 to n-1)","ṁṁ\ncmap \n(x -> [y]) -> [x] -> [y] \nMap function over list and concat the result","ȯȯ\n\nToo many to list \nComposition of three functions; ȯABC is roughly equivalent to oAoBC","ṗṗ\nisprime \nTNum -> TNum \nReturn the index of the argument in the list of all primes, or 0 if it is not a prime number","ṙṙ\nrotate \nTNum -> [a] -> [a] \nRotate n steps to the left","ṡṡ\nsrange \nTNum -> [TNum] \nSymmetric range (from -n to n)","ṫṫ\ntails \n(Concrete x) => x -> [x] \nSuffixes for lists, reversed range for numbers","żż\nzip' \n(a -> a -> a) -> [a] -> [a] -> [a] \nLike zip, but keeps trailing elements from the longer list unchanged.","¨¨\nDieresis \n\nDelimiter for compressed strings","ËË\nsameon \nConcrete y => (x -> y) -> [x] -> TNum \nAre function results all equal? Returns length + 1 or 0.","ÖÖ\nsorton \n(Concrete y) => (x -> y) -> [x] -> [x] \nSort by function result","ëë\nlist4 \nx -> x -> x -> x -> [x] \nCreate a list with four elements","öö\n\nToo many to list \nComposition of four functions; öABCD is roughly equivalent to oAoBoCD","üü\nnubon \n(Concrete x) => (x -> y) -> [x] -> [x] \nRemove duplicates by function result","øø\nempty \n[x] \nEmpty list","□□\nsquare \nTNum -> TNum \nRaise to second power","¶¶\nlines \n[TChar] -> [[TChar]] \nSplit on newlines","««\nmapacL \n(x -> y -> x) -> (x -> y -> z) -> x -> [y] -> [z] \nScanl over a list with the first function, but results are produced by applying the second function to intermediate steps","»»\nmapacR \n(y -> x -> x) -> (y -> x -> z) -> x -> [y] -> [z] \nScanr over a list with the first function, but results are produced by applying the second function to intermediate steps"] -,bqk=''.replace(/∙/g,'') -,bqv=''.replace(/∙/g,'') -,tc={},bqc={} //tab completions and ` completions -for(let i=0;i') - for(let j=0;j'+lbs[i][0]+'' -} -let d=document,el=d.createElement('div');el.innerHTML= -`
${lbh}
- +; (_ => { + let hc = { '<': '<', '&': '&', "'": ''', '"': '"' }, he = x => x.replace(/[<&'"]/g, c => hc[c]) //html chars and escape fn + , tcs = "cur¤hlf½ud.↕up.↑dow↓lr.↔lft←rgt→bar¦exc¡dex‼ell…ppm‰dag†ddg‡srd√leq≤geq≥pm.±ptl∂int∫inf∞apx≈neq≠cng≡neg¬div÷eks×blt·nul₀one₁two₂thr₃fou₄fiv₅six₆sev₇eig₈nin₉lce⌈rce⌉lfl⌊rfl⌋GamΓTheΘLamΛXi.ΞPi.ΠSigΣPsiΨOhmΩdelδepsεetaηlamλmu.μxi.ξpi.πsjgσphiφchiχpsiψohmωNul⁰One¹Two²Thr³Fou⁴Fiv⁵Six⁶Sev⁷Eig⁸Nin⁹cnt¢gbp£eur€yen¥fl.ƒacu´top▲bot▼est►wst◄sec§dC.ĊdD.ḊdF.ḞdG.ĠdI.İdM.ṀdP.ṖdR.ṘdS.ṠdT.ṪdX.Ẋdd.ḋde.ėdf.ḟdg.ġdh.ḣdl.ŀdm.ṁdo.ȯdp.ṗdr.ṙds.ṡdt.ṫdz.żdie¨DE.ËDO.ÖDe.ëDo.öDu.üso.øsqu□pgf¶ll.«rr.»" + , lbs = ["¤¤\ncombin \n(y -> y -> z) -> (x -> y) -> x -> x -> z \nCompose both arguments of binary function", "½½\nhalve \nTNum -> TNum \nDivide by 2", "↕↕\nspan \n(Concrete y) => (x -> y) -> [x] -> ([x], [x]) \nSplit at first value where function gives falsy result", "↑↑\ntake \nTNum -> [x] -> [x] \nTake n elements from list. Negative n takes from the end", "↓↓\ndrop \nTNum -> [x] -> [x] \nDrop n elements from list. Negative n drops from the end", "↔↔\nswap \n(x, y) -> (y, x) \nSwap a pair", "←←\nhead \n[x] -> x \nFirst value of a list", "→→\nlast \n[x] -> x \nLast value of a list", "\\\\\nNewline \n\nSeparates lines in program", "¦¦\ndivds \nTNum -> TNum -> TNum \n1 if b == 0, b / a if a divides b, 0 otherwise", "¡¡\niter \n(x -> x) -> x -> [x] \nApply function repeatedly, collect values in infinite list", "‼‼\ntwice \n(x -> x) -> (x -> x) \nApply function twice", "……\nrangeN \nTNum -> TNum -> [TNum] \nInclusive numeric range", "‰‰\ndivmod \nTNum -> TNum -> [TNum] \nTwo-element list [b ÷ a, b % a]", "††\nvec \n(Vect a b x y) => (a -> b) -> x -> y \nVectorize a function (\"deep map\")", "‡‡\nvec2 \n(Vect2 a b c x y z) => (a -> b -> c) -> x -> y -> z \nBi-vectorize a function (\"deep zip\")", "√√\nsqrt \nTNum -> TNum \nSquare root", "≤≤\nle \n(Concrete x) => x -> x -> TNum \nLess than or equal", "≥≥\nge \n(Concrete x) => x -> x -> TNum \nGreater than or equal", "±±\nsign \nTNum -> TNum \nSign of a number", "∂∂\nadiags \n[[x]] -> [[x]] \nAntidiagonals", "∫∫\ncumsum \n[TNum] -> [TNum] \nCumulative sum", "∞∞\nrep \nx -> [x] \nInfinite list of copies of the argument", "≈≈\nsimil \n(Concrete x) => x -> x -> TNum \nSimilar. For numbers or chars checks if the absolute difference is <=1. For lists checks if they are the same length. For Pairs checks if both elements are similar.", "≠≠\nneq \n(Concrete x) => x -> x -> TNum \nNot equal", "≡≡\ncongr \n(Concrete x) => x -> x -> TNum \nRecursively check if the two arguments have the same shape and the same distribution of truthy/falsy values. Returns 1 or 0.", "¬¬\nnot \n(Concrete x) => x -> TNum \nNegation of truthiness", "÷÷\nidiv \nTNum -> TNum -> TNum \nInteger division", "××\nmix \n(x -> y -> z) -> [x] -> [y] -> [z] \nFunction applied to all pairs drawn from the lists", "!!\nindex \nTNum -> [x] -> x \nValue at modular index", "\\\\\ninv \nTNum -> TNum \nReciprocal number", "\"\"\nDouble quote \n\nString delimiter", "##\ncountf \n(Concrete y) => (x -> y) -> [x] -> TNum \nNumber of list elems where function result is truthy", "%%\nmod \nTNum -> TNum -> TNum \nModulus of second argument by first", "&&\nand \n(Concrete x) => x -> x -> x \nSecond argument if falsy, else first", "''\nSingle quote \n\nCharacter delimiter", "((\nParentheses \n\nGroup expressions", "**\nmul \nTNum -> TNum -> TNum \nMultiply numbers", "++\nadd \nTNum -> TNum -> TNum \nAdd numbers", ",,\npair \nx -> y -> (x, y) \nConstruct pair", "--\nsub \nTNum -> TNum -> TNum \nSubtract first argument from second", "..\nDecimal point \n\nUsed in floating point literals", "//\ndiv \nTNum -> TNum -> TNum \nExact division, uses rational numbers when possible", "::\ncons \nx -> [x] -> [x] \nPrepend a value to a list", ";;\npure \nx -> [x] \nCreate singleton list", "<<\nlt \n(Concrete x) => x -> x -> TNum \nLess than", "==\neq \n(Concrete x) => x -> x -> TNum \nEquals", ">>\ngt \n(Concrete x) => x -> x -> TNum \nGreater than", "??\nif \n(Concrete x) => y -> y -> x -> y \nTernary if conditioned on third argument", "AA\nmean \n[TNum] -> TNum \nAverage of a list", "BB\nbase \nTNum -> TNum -> [TNum] \nDigits in given base", "CC\ncut \nTNum -> [a] -> [[a]] \nCut into sublists of given length. Negative n counts lengths from the end.", "DD\ndouble \nTNum -> TNum \nMultiply by 2", "EE\nsame \nConcrete x => [x] -> TNum \nLength plus 1 if all elements are equal, else 0", "FF\nfoldl \n(y -> x -> y) -> y -> [x] -> y \nLeft fold", "GG\nscanl \n(y -> x -> y) -> y -> [x] -> [y] \nScan from left", "II\nid \nx -> x \nIdentity function", "JJ\njoin \n[x] -> [[x]] -> [x] \nJoin by a list", "KK\nconst \nx -> y -> x \nConstant function", "LL\nlen \n[x] -> TNum \nLength of list", "MM\nlmap \n(x -> y -> z) -> [x] -> y -> [z] \nMap over left argument", "NN\nnats \n[TNum] \nInfinite list of natural numbers", "OO\nsort \n(Concrete x) => [x] -> [x] \nSort list in ascending order", "PP\nperms \n[a] -> [[a]] \nList of all permutations of the given list", "QQ\nslices \n[a] -> [[a]] \nAll contiguous sublists", "RR\nreplic \nTInt -> a -> [a] \nList composed by a given number of copies of a value", "SS\nhook \n(x -> y -> z) -> (x -> y) -> x -> z \nS-combinator", "TT\ntrsp \n[[a]] -> [[a]] \nTranspose a 2-d list, elements missing from shorter rows are skipped", "UU\nnubw \nConcrete a => [a] -> [a] \nLongest prefix of a list with all unique elements", "VV\nany \nConcrete b => (a->b) -> [a] -> TNum \nIndex of first element satisfying predicate, 0 if not found", "WW\nwhere \nConcrete b => (a->b) -> [a] -> [TNum] \nIndices of elements satisfying predicate", "XX\nslice \nTNum -> [a] -> [[a]] \nAll subslists of length n. Negative n includes final stubs.", "YY\nmax \n(Concrete x) => x -> x -> x \nMaximum of two values", "^^\npower \nTNum -> TNum -> TNum \nSecond argument raised to the power of the first", "__\nneg \nTNum -> TNum \nNegate a number", "``\nflip \n(x -> y -> z) -> y -> x -> z \nInvert order of arguments", "aa\nabs \nTNum -> TNum \nAbsolute value", "cc\nchr \nTNum -> TChar \nConvert integer to character", "dd\nbase10 \nTNum -> [TNum] \nBase-10 digits", "ee\nlist2 \nx -> x -> [x] \nCreate a list with two elements", "ff\nfilter \n(Concrete y) => (x -> y) -> [x] -> [x] \nFilter list by predicate", "gg\ngroup \n(Concrete x) => [x] -> [[x]] \nGroup equal adjacent values", "hh\ninit \n[x] -> [x] \nRemove last element", "ii\nd2i \nTDouble -> TNum \nConvert from Double to Int by rounding (round half to even)", "kk\nkeyon \nConcrete y => (x -> y) -> [x] -> [[x]] \nGroup list elements into classes by function value. Classes are ordered by the function values.", "mm\nmap \n(x -> y) -> [x] -> [y] \nMap function over list", "nn\nbwand \nTNum -> TNum -> TNum \nBitwise AND", "oo\ncom \n(y -> z) -> (x -> y) -> x -> z \nFunction composition", "pp\npfac \nTNum -> [TNum] \nPrime factorization", "rr\nread \n(Concrete x) => [TChar] -> x \nConvert string to value", "ss\nshow \n(Concrete x) => x -> [TChar] \nConvert value to string", "tt\ntail \n[x] -> [x] \nRemove first element", "uu\nnub \n(Concrete x) => [x] -> [x] \nRemove duplicates", "vv\nbwor \nTNum -> TNum -> TNum \nBitwise OR", "ww\nwords \n[TChar] -> [[TChar]] \nSplit on spaces", "xx\nsplit \nConcrete x => x -> [x] -> [[x]] \nSplit on given element", "yy\nmin \n(Concrete x) => x -> x -> x \nMinimum of two values", "zz\nzip \n(x -> y -> z) -> [x] -> [y] -> [z] \nZip lists with function", "||\nor \n(Concrete x) => x -> x -> x \nSecond argument if truthy, else first", "~~\nbranch \n(x -> y -> z) -> (u -> x) -> (v -> y) -> (u -> v -> z) \nCompose both arguments of binary function separately", "··\ncomf \n(x -> y -> z) -> (u -> y) -> (x -> u -> z) \nCompose second argument of function", "₀₀\nSubscript digit\n\nLine label", "₁₁\nSubscript digit\n\nLine label", "₂₂\nSubscript digit\n\nLine label", "₃₃\nSubscript digit\n\nLine label", "₄₄\nSubscript digit\n\nLine label", "₅₅\nSubscript digit\n\nLine label", "₆₆\nSubscript digit\n\nLine label", "₇₇\nSubscript digit\n\nLine label", "₈₈\nSubscript digit\n\nLine label", "₉₉\nSubscript digit\n\nLine label", "⌈⌈\nceil \nTNum -> TNum \nCeiling function", "⌉⌉\nlcm \nTNum -> TNum -> TNum \nLowest common multiple", "⌊⌊\nfloor \nTNum -> TNum \nFloor function", "⌋⌋\ngcd \nTNum -> TNum -> TNum \nGreatest common divisor", "ΓΓ\nlist \ny -> (x -> [x] -> y) -> [x] -> y \nPattern match on list", "ΘΘ\nprep0 \n[x]->[x] \nPrepends a default value of the appropriate type to a list. Default values are either falsy values (0,[],...) or functions returning those values.", "ΛΛ\nall \nConcrete b => (a->b) -> [a] -> TNum \nLength + 1 if all elements satisfy predicate, else 0", "ΞΞ\nmerge \nConcrete a => [[a]] -> [a] \nMerge a list of lists. Each list should be ordered, and if there are more than 2 lists, their heads should also be ordered. Works on infinite lists.", "ΠΠ\nprod \n[TNum] -> TNum \nProduct of list", "ΣΣ\nsum \n[TNum] -> TNum \nSum of list", "ΨΨ\ntoadjM \n(((a, a) -> c) -> [(a,a)] -> [[(a, a)]]) -> (a -> a -> c) -> [a] -> [[a]] \nApply higher-order function on adjacent pairs instead of single elements", "ΩΩ\nuntil \nConcrete y => (x -> y) -> (x -> x) -> x -> x \nIterate function until test result is truthy", "δδ\ndecorM \n(((a, b) -> c) -> [(a,b)] -> [[(a,d)]]) -> (a -> b -> c) -> [a] -> [b] -> [[d]] \nApply higher-order function using auxiliary list", "εε\nsmall \nTNum -> TNum \nHas absolute value at most 1", "ηη\nonixes \n((TNum -> a) -> [TNum] -> b) -> [a] -> b \nAct on list of indices using indexing function. If α is a function, ηα is roughly equivalent to α§!ŀ.", "λλ\nSmall lambda \n\nOne-argument anonymous function", "μμ\nSmall mu \n\nTwo-argument anonymous function", "ξξ\nSmall xi \n\nThree-argument anonymous function", "ππ\ncpow \nTNum -> [x] -> [[x]] \nCartesian power", "σσ\nsubs \n(Concrete x) => [x] -> [x] -> [x] \nSubstitute list elements according to mapping. Each element is mapped to the one after its first occurrence, or itself.", "φφ\nSmall phi \n\nSelf-referential anonymous function", "χχ\nSmall chi \n\nSelf-referential anonymous function with 2 extra arguments", "ψψ\nSmall psi \n\nSelf-referential anonymous function with extra argument", "ωω\nfixp \n(Concrete x) => (x -> x) -> x -> x \nFind periodic point by iterating", "⁰⁰\nSuperscript digit\n\nLambda argument", "¹¹\nSuperscript digit\n\nLambda argument", "²²\nSuperscript digit\n\nLambda argument", "³³\nSuperscript digit\n\nLambda argument", "⁴⁴\nSuperscript digit\n\nLambda argument", "⁵⁵\nSuperscript digit\n\nLambda argument", "⁶⁶\nSuperscript digit\n\nLambda argument", "⁷⁷\nSuperscript digit\n\nLambda argument", "⁸⁸\nSuperscript digit\n\nLambda argument", "⁹⁹\nSuperscript digit\n\nLambda argument", "¢¢\ncycle \n[x] -> [x] \nRepeat list infinitely", "££\noelem \n(Concrete x) => [x] -> x -> TNum \nLike elem, but the list is supposed to be sorted", "€€\nelem \n(Concrete x) => [x] -> x -> TNum \nIndex of first occurrence, or 0 if not found", "¥¥\nixsof \n(Concrete x) => x -> [x] -> [TNum] \nIndices of occurrence", "ƒƒ\nfix \n(x -> x) -> x \nLeast fixed point (used for recursion)", "´´\nargdup \n(x -> x -> y) -> x -> y \nApply twice to same argument", "▲▲\nmaxl \n(Concrete x) => [x] -> x \nMaximum of list", "▼▼\nminl \n(Concrete x) => [x] -> x \nMinimum of list", "►►\nmaxlby \nConcrete y => (x -> x -> y) -> [x] -> x \nMaximum element with custom ordering predicate", "◄◄\nminlby \nConcrete y => (x -> x -> y) -> [x] -> x \nMinimum element with custom ordering predicate", "§§\nfork \n(x -> y -> z) -> (u -> x) -> (u -> y) -> u -> z \nCompose each argument of binary function", "ĊĊ\ngaps \nTNum -> [a] -> [a] \nTake every abs(n)'th element, starting from the first if n is positive, from the -n-1st if negative", "ḊḊ\ndivs \nTNum -> [TNum] \nList of divisors", "ḞḞ\nfoldr \n(x -> y -> y) -> y -> [x] -> y \nRight fold", "ĠĠ\nscanr \n(x -> y -> y) -> y -> [x] -> [y] \nScan from right", "İİ\nDotted capital I \n\nAccess built-in numeric sequences", "ṀṀ\nrmap \n(x -> y -> z) -> x -> [y] -> [z] \nMap over right argument", "ṖṖ\npowset \n[x] -> [[x]] \nAll finite subsequences", "ṘṘ\nclone \nTNum -> [x] -> [x] \nReplicate each element by given number", "ṠṠ\nhookf \n(x -> y -> z) -> (y -> x) -> y -> z \nLike S, but composes on other argument", "ṪṪ\ntable \n(x -> y -> z) -> [x] -> [y] -> [[z]] \nOuter product, or \"multiplication table\"", "ẊẊ\nmapad2 \n(x -> x -> y) -> [x] -> [y] \nMap over pairs of adjacent values", "ḋḋ\nbase2 \nTNum -> [TNum] \nBinary digits", "ėė\nlist3 \nx -> x -> x -> [x] \nCreate a list with three elements", "ḟḟ\nfind \n(Concrete y) => (x -> y) -> [x] -> x \nReturn first value that gives truthy result", "ġġ\ngroupOn \n(Concrete y) => (x -> y) -> [x] -> [[x]] \nGroup on function result", "ḣḣ\nheads \n(Concrete x) => x -> [x] \nPrefixes for lists, range for numbers", "ŀŀ\nlrange \nTNum -> [TNum] \nLowered range (from 0 to n-1)", "ṁṁ\ncmap \n(x -> [y]) -> [x] -> [y] \nMap function over list and concat the result", "ȯȯ\n\nToo many to list \nComposition of three functions; ȯABC is roughly equivalent to oAoBC", "ṗṗ\nisprime \nTNum -> TNum \nReturn the index of the argument in the list of all primes, or 0 if it is not a prime number", "ṙṙ\nrotate \nTNum -> [a] -> [a] \nRotate n steps to the left", "ṡṡ\nsrange \nTNum -> [TNum] \nSymmetric range (from -n to n)", "ṫṫ\ntails \n(Concrete x) => x -> [x] \nSuffixes for lists, reversed range for numbers", "żż\nzip' \n(a -> a -> a) -> [a] -> [a] -> [a] \nLike zip, but keeps trailing elements from the longer list unchanged.", "¨¨\nDieresis \n\nDelimiter for compressed strings", "ËË\nsameon \nConcrete y => (x -> y) -> [x] -> TNum \nAre function results all equal? Returns length + 1 or 0.", "ÖÖ\nsorton \n(Concrete y) => (x -> y) -> [x] -> [x] \nSort by function result", "ëë\nlist4 \nx -> x -> x -> x -> [x] \nCreate a list with four elements", "öö\n\nToo many to list \nComposition of four functions; öABCD is roughly equivalent to oAoBoCD", "üü\nnubon \n(Concrete x) => (x -> y) -> [x] -> [x] \nRemove duplicates by function result", "øø\nempty \n[x] \nEmpty list", "□□\nsquare \nTNum -> TNum \nRaise to second power", "¶¶\nlines \n[TChar] -> [[TChar]] \nSplit on newlines", "««\nmapacL \n(x -> y -> x) -> (x -> y -> z) -> x -> [y] -> [z] \nScanl over a list with the first function, but results are produced by applying the second function to intermediate steps", "»»\nmapacR \n(y -> x -> x) -> (y -> x -> z) -> x -> [y] -> [z] \nScanr over a list with the first function, but results are produced by applying the second function to intermediate steps"] + , bqk = ''.replace(/∙/g, '') + , bqv = ''.replace(/∙/g, '') + , tc = {}, bqc = {} //tab completions and ` completions + for (let i = 0; i < bqk.length; i++)bqc[bqk[i]] = bqv[i] + for (let i = 0; i < tcs.length; i += 4)tc[tcs[i] + tcs[i + 1] + tcs[i + 2]] = tcs[i + 3] + for (let i = 0; i < tcs.length; i += 4) { let k = tcs[i + 2] + tcs[i + 1] + tcs[i]; tc[k] = tc[k] || tcs[i + 3] } + let lbh = ''; for (let i = 0; i < lbs.length; i++) { + let ks = [] + for (let j = 0; j < tcs.length; j += 4)if (lbs[i][0] === tcs[j + 3]) ks.push('\n' + tcs[j] + tcs[j + 1] + tcs[j + 2] + ' ') + for (let j = 0; j < bqk.length; j++)if (lbs[i][0] === bqv[j]) ks.push('\n` ' + bqk[j]) + lbh += '' + lbs[i][0] + '' + } + let d = document, el = d.createElement('div'); el.innerHTML = + `
${lbh}
+ ` -d.body.appendChild(el) -let t,ts=[],lb=el.firstChild,bqm=0 //t:textarea or input, lb:language bar, bqm:backquote mode -let pd=x=>x.preventDefault() -let ev=(x,t,f,c)=>x.addEventListener(t,f,c) -ev(lb,'mousedown',x=>{ - if(x.target.classList.contains('ngn_x')){lb.hidden=1;upd();pd(x);return} - if(x.target.nodeName==='B'&&t){ - let i=t.selectionStart,j=t.selectionEnd,v=t.value,s=x.target.textContent - if(i!=null&&j!=null){t.value=v.slice(0,i)+s+v.slice(j);t.selectionStart=t.selectionEnd=i+s.length} - pd(x);return - } -}) -let fk=x=>{ - let t=x.target - if(bqm){let i=t.selectionStart,v=t.value,c=bqc[x.key];if(x.which>31){bqm=0;d.body.classList.remove('ngn_bq')} - if(c){t.value=v.slice(0,i)+c+v.slice(i);t.selectionStart=t.selectionEnd=i+1;pd(x);return!1}} - switch(x.ctrlKey+2*x.shiftKey+4*x.altKey+8*x.metaKey+100*x.which){ - case 900:{let i=t.selectionStart,v=t.value,c=tc[v.slice(i-3,i)] //tab - if(c){t.value=v.slice(0,i-3)+c+v.slice(i);t.selectionStart=t.selectionEnd=i-1;pd(x)} - break} - } -} -let ff=x=>{ - let t0=x.target,nn=t0.nodeName.toLowerCase() - if(nn!=='textarea'&&(nn!=='input'||t0.type!=='text'&&t0.type!=='search'))return - t=t0;if(!t.ngn){t.ngn=1;ts.push(t);ev(t,'keydown',fk)} -} -let upd=_=>{d.body.style.marginTop=lb.clientHeight+'px'} -upd();ev(window,'resize',upd) -ev(d,'focus',ff,!0);let ae=d.activeElement;ae&&ff({type:'focus',target:ae}) + d.body.appendChild(el) + let t, ts = [], lb = el.firstChild, bqm = 0 //t:textarea or input, lb:language bar, bqm:backquote mode + let pd = x => x.preventDefault() + let ev = (x, t, f, c) => x.addEventListener(t, f, c) + ev(lb, 'mousedown', x => { + if (x.target.classList.contains('ngn_x')) { lb.hidden = 1; upd(); pd(x); return } + if (x.target.nodeName === 'B' && t) { + let i = t.selectionStart, j = t.selectionEnd, v = t.value, s = x.target.textContent + if (i != null && j != null) { t.value = v.slice(0, i) + s + v.slice(j); t.selectionStart = t.selectionEnd = i + s.length } + pd(x); return + } + }) + let fk = x => { + let t = x.target + if (bqm) { + let i = t.selectionStart, v = t.value, c = bqc[x.key]; if (x.which > 31) { bqm = 0; d.body.classList.remove('ngn_bq') } + if (c) { t.value = v.slice(0, i) + c + v.slice(i); t.selectionStart = t.selectionEnd = i + 1; pd(x); return !1 } + } + switch (x.ctrlKey + 2 * x.shiftKey + 4 * x.altKey + 8 * x.metaKey + 100 * x.which) { + case 900: { + let i = t.selectionStart, v = t.value, c = tc[v.slice(i - 3, i)] //tab + if (c) { t.value = v.slice(0, i - 3) + c + v.slice(i); t.selectionStart = t.selectionEnd = i - 1; pd(x) } + break + } + } + } + let ff = x => { + let t0 = x.target, nn = t0.nodeName.toLowerCase() + if (nn !== 'textarea' && (nn !== 'input' || t0.type !== 'text' && t0.type !== 'search')) return + t = t0; if (!t.ngn) { t.ngn = 1; ts.push(t); ev(t, 'keydown', fk) } + } + let upd = _ => { d.body.style.marginTop = lb.clientHeight + 'px' } + upd(); ev(window, 'resize', upd) + ev(d, 'focus', ff, !0); let ae = d.activeElement; ae && ff({ type: 'focus', target: ae }) })(); diff --git a/index.html b/index.html index ccb59cd..05a1b88 100644 --- a/index.html +++ b/index.html @@ -1,23 +1,31 @@ - - LB - - - - - + + + + LB + + + + + + + \ No newline at end of file diff --git a/jelly.js b/jelly.js index 3e6ea64..300b0c1 100644 --- a/jelly.js +++ b/jelly.js @@ -1,22 +1,22 @@ -;(_=>{ -let hc={'<':'<','&':'&',"'":''','"':'"'},he=x=>x.replace(/[<&'"]/g,c=>hc[c]) //html chars and escape fn -,tcs="v!¡|c¢-L£^o¤=Y¥^|¦oC©^_¬oR®^uµ/2½v?¿CE€AEÆC,Ç-DÐ~NÑ^*×/OØOEŒ|PÞ^Sßaeæc,ç^dð^iı^jȷ~nñ^/÷/oøoeœ|pþ\\n¶^0°^1¹^2²^3³^4⁴^5⁵^6⁶^7⁷^8⁸^9⁹^+⁺^-⁻^=⁼^(⁽^)⁾`BƁC'Ƈ`DƊ,FƑG'ƓK'ƘM,Ɱ,NƝ`PƤ`TƬ`UƲZ,Ȥ`bɓc'ƈd'ɗ,fƒg'ɠh'ɦk'ƙm,ɱ,nɲp'ƥq'ʠ,rɼ,sʂt'ƭ`uʋz,ȥ.AẠ.BḄ.DḌ.EẸ.HḤ.IỊ.KḲ.LḶ.MṂ.NṆ.OỌ.RṚ.SṢ.TṬ.U§.VÄ.WẈ.YỴ.ZẒA.ȦB.ḂC.ĊD.ḊE.ĖF.ḞG.ĠH.ḢI.İL.ĿM.ṀN.ṄO.ȮP.ṖR.ṘS.ṠT.ṪW.ẆX.ẊY.ẎZ.Ż.aạ.bḅ.dḍ.eẹ.hḥ.iị.kḳ.lḷ.mṃ.nṇ.oọ.rṛ.sṣ.tṭ.u§.vÄ.wẉ.yỵ.zẓa.ȧb.ḃc.ċd.ḋe.ėf.ḟg.ġh.ḣl.ŀm.ṁn.ṅo.ȯp.ṗr.ṙs.ṡt.ṫw.ẇx.ẋy.ẏz.ż<<«>>»^'‘^,’^\"“\"\"”" -,lbs=["®®\nnilad\nRestore; retrieve the value of the register. Initially 0.","³³\nnilad\nReturn the third command line argument (first input) or 100.","⁴⁴\nnilad\nReturn the fourth command line argument (second input) or 16.","⁵⁵\nnilad\nReturn the fifth command line argument (third input) or 10.","⁶⁶\nnilad\nReturn the sixth command line argument (fourth input) or ' '.","⁷⁷\nnilad\nReturn the seventh command line argument (fifth input) or '\\n'.","⁸⁸\nnilad\nReturn the link's left argument or [].","⁹⁹\nnilad\nReturn the link's right argument or 256.","ƓƓ\nnilad\nRead and evaluate a single line from STDIN.","ƈƈ\nnilad\nRead a single character from STDIN.","ɠɠ\nnilad\nRead a single line from STDIN."," \nSYNTAX\nToken separator.","¬¬\nmonad\nLogical NOT: if z is zero or empty, then 1, else 0.","½½\nmonad\nSquare root.\n\nƽ\nmonad\nCompute the integer square root of z.","!!\nmonad\nFactorial or Pi function.\n\nÆ!\nmonad\nConvert from integer to factorial base.\n\nŒ!\nmonad\nAll permutations of z. May contain duplicates.","AA\nmonad\nAbsolute value.\n\nØA\nnilad\nAlphabet; yield 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'.\n\nÆA\nmonad\nArccosine.\n\næA\ndyad\nArctangent with two arguments, i.e., atan2().","BB\nmonad\nConvert from integer to binary.\n\nØB\nnilad\nBase digits; yield '0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz'.\n\nŒB\nmonad\nBounce; yield z[:-1] + z[::-1]. Vectorizes at depth 1.","CC\nmonad\nComplement; compute 1 − z.\n\nØC\nnilad\nConsonants; yield 'BCDFGHJKLMNPQRSTVWXYZbcdfghjklmnpqrstvwxyz'.\n\nÆC\nmonad\nCount the primes less or equal to z.","DD\nmonad\nConvert from integer to decimal.\n\nØD\nnilad\nDigits; yield '0123456789'.\n\nÆD\nmonad\nCompute the array of z's divisors.\n\nŒD\nmonad\nDiagonals of a matrix. Starts with the main diagonal.","EE\nmonad\nCheck if all elements of z are equal.\n\nÆE\nmonad\nCompute the array of exponents of z's prime factorization. Includes zero exponents.","FF\nmonad\nFlatten list.\n\nÆF\nmonad\nCompute z's prime factorization as [prime, exponent] pairs.","GG\nmonad\nAttempt to format z as a grid.\n\nŒG\nmonad\nGET request z. http:// is prepended by default.","HH\nmonad\nHalve; compute z ÷ 2.\n\nØH\nnilad\nHexadecimal digits; yield '0123456789ABCDEF'.","II\nmonad\nIncrements; compute the differences of consecutive elements of z.","JJ\nmonad\nReturns [1 … len(z)].\n\nØJ\nnilad\nYield Jelly's codepage.","KK\nmonad\nJoin z, separating by spaces.","LL\nmonad\nLength.\n\nÐL\nQuick\nLoop. Repeat until the results are no longer unique.\nÐL","MM\nmonad\nReturn all indices of z that correspond to maximal elements.","NN\nmonad\nNegative; compute −z.\n\nÆN\nmonad\nGenerate the zth prime.","OO\nmonad\nOrd; cast to number.","PP\nmonad\nProduct of a list.\n\nØP\nnilad\nPi\n\nÆP\nmonad\nIf z is a prime, then 1, else 0.\n\nŒP\nmonad\nPowerset of z. May contain duplicates.","QQ\nmonad\nReturn the unique elements of z, sorted by first appearance.\n\nØQ\nnilad\nQwerty; yield ['QWERTYUIOP', 'ASDFGHJKL', 'ZXCVBNM'].\n\nŒQ\nmonad\nDistinct sieve.","RR\nmonad\nInclusive range [1 … z].\n\nÆR\nmonad\nRange; generate all primes between 2 and z.\n\næR\ndyad\nInclusive prime range, from x to y.\n\nŒR\nmonad\nList from −abs(z) to abs(z) inclusive (shorthand for Ar@N$).","SS\nmonad\nSum of a list.\n\nÆS\nmonad\nSine.\n\nœS\ndyad\nAfter sleeping for y seconds, return x.","TT\nmonad\nReturn all indices of z that correspond to truthy elements.\n\nÆT\nmonad\nTangent.\n\nŒT\nmonad\nFormat time: Let the last three bits of z be abc. If a is 1, include the time; if b is 1, include the minute; if c is 1, include the second.","UU\nmonad\nUpend; reverse an array.","VV\nmonad\nEval z as Jelly code, with no arguments. If z is a list, it maps Python's str function to all of z's elements, concatenates them and then eval's the result. Vectorizes at depth 1.\n\nØV\nnilad\nYield 'ṘV' (a cheat for writing a quine\n\nŒV\nmonad\nEvaluate Python code z.","WW\nmonad\nWrap; return [z].\n\nØW\nnilad\nWord; yield 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789_'","XX\nmonad\nRandom; choose a random item from z if z is a list, or from 1 to z inclusive if z is a positive integer. If z = 0, return z. Error if z is negative or a decimal.","YY\nmonad\nJoin z, separating by linefeeds.\n\nØY\nnilad\nConsonants; yield 'BCDFGHJKLMNPQRSTVWXZbcdfghjklmnpqrstvwxz'.","ZZ\nmonad\nZip; push the array of all columns of z.","~~\nmonad\nBitwise NOT.","°°\nmonad\nConvert z from degrees to radians.\n\nÆ°\nmonad\nConvert z from radians to degrees.","¹¹\nmonad\nIdentity; return z.","²²\nmonad\nSquare.\n\nƲ\nmonad\nIf z is a square, then 1, else 0.","ẠẠ\nmonad\nAll; return 0 if z contains a falsey value, else 1.\n\nÆẠ\nmonad\nCosine.","ḄḄ\nmonad\nConvert from binary to integer.\n\nŒḄ\nmonad\nBounce; yield z[:-1] + z[::-1]. Does not vectorize.","ḌḌ\nmonad\nConvert from decimal to integer.\n\nÆḌ\nmonad\nProper divisors.\n\nŒḌ\nmonad\nReconstruct matrix from its diagonals.","ẸẸ\nmonad\nAny; return 1 if z contains a truthy value, else 0.\n\nÆẸ\nmonad\nInverse of ÆE.","ḤḤ\nmonad\nDouble; compute 2z.","ỊỊ\nmonad\nInsignificant; return abs(z) ≤ 1.","ḲḲ\nmonad\nSplit z at spaces.","ḶḶ\nmonad\nLowered range; return [0 … z−1].\n\nÐḶ\nQuick\nLike ÐL. Collects all results in the loop.","ṂṂ\nmonad\nMinimum.\n\nÐṂ\nQuick\nKeep elements with minimal link value; [e for e in z if link(e) == min(map(link, z))].\nÐṂ","ṆṆ\nmonad\nLogical NOT. Does not vectorize.","ỌỌ\nmonad\nChr; cast to character.","ṚṚ\nmonad\nReverse z. Does not vectorize.","ṢṢ\nmonad\nSort the list z.\n\nÆṢ\nmonad\nArcsine.","ṬṬ\nmonad\nReturn a Boolean array with 1's at the indices in z.\n\nÆṬ\nmonad\nArctangent.","§§\nmonad\nGrade the list z up, i.e., sort its indices by their values.","ÄÄ\nmonad\nUneval; right inverse of V.","ỴỴ\nmonad\nSplit z at linefeeds.","ȦȦ\nmonad\nAny and all; return 0 if z is empty, or contains a falsey value when flattened, else 1.","ḂḂ\nmonad\nBit; return z % 2.\n\nŒḂ\nmonad\nCheck if z is a palindrome. For integers, short for DŒḂ$.","ĊĊ\nmonad\nCeil; round z up to the nearest integer. Imag. part for complex z.\n\nÆĊ\nmonad\nReturns the zth Catalan number","ḊḊ\nmonad\nDequeue; return z[1:].\n\nÆḊ\nmonad\nDeterminant. For non-square z, computes det(zzT)½; if z is a row vector, this is its norm.\n\nŒḊ\nmonad\nDepth.","ĖĖ\nmonad\nEnumerate; return [ [1,y[1]] , [2,y[2]], ... ].","ḞḞ\nmonad\nFloor; round z down to the nearest integer. Real part for complex z.\n\nÆḞ\nmonad\nReturns the zth item in the Fibonacci sequence.","ĠĠ\nmonad\nGroup the indices of z by their corresponding values.","ḢḢ\nmonad\nHead; pop and return the first element of z. Modifies z.","İİ\nmonad\nInverse; compute 1 ÷ z.","ṀṀ\nmonad\nMaximum.\n\nÐṀ\nQuick\nKeep elements with maximal link value; [e for e in z if link(e) == max(map(link, z))].\nÐṀ","ṄṄ\nmonad\nPrint z and a linefeed. Returns z.","ȮȮ\nmonad\nPrint z. Returns z.","ṖṖ\nmonad\nPop; return z[:-1].\n\nØṖ\nnilad\nYield the set of printable ASCII chars.\n\nŒṖ\nmonad\nPartition of z (z must be a list).","ṘṘ\nmonad\nPrint a string representation of z, without a linefeed. Returns z.\n\nŒṘ\nmonad\nPython's string representation.","ṠṠ\nmonad\nSign of z. Conjugate for complex z.","ṪṪ\nmonad\nTail; pop and return the last element of z. Modifies z.\n\nÆṪ\nmonad\nTotient function.","ẆẆ\nmonad\nSublists; all non-empty contiguous slices of z.","ẊẊ\nmonad\nShuffle; return a random permutation of z.","ẎẎ\nmonad\nTighten; dump all lists inside z.","‘‘\nmonad\nIncrement; compute z + 1.","’’\nmonad\nDecrement; compute z − 1."," \nSYNTAX\nToken separator.","××\ndyad\nMultiplication.\n\næ×\ndyad\nMatrix multiplication.","÷÷\ndyad\nFloating point division.","%%\ndyad\nModulus.\n\næ%\ndyad\nSymmetric modulo 2y; map x in the interval (−y, y]. Try 100Ræ%4 to get the hang of it.","&&\ndyad\nBitwise AND.\n\nœ&\ndyad\nMultiset intersection.","**\ndyad\nExponentiation with base x.\n\næ*\ndyad\nMatrix power.","++\ndyad\nAddition.",",,\ndyad\nPair; return [x, y].","::\ndyad\nInteger division.",";;\ndyad\nConcatenate.","<<\ndyad\nIf x is less than y, then 1, else 0.","==\ndyad\nIf x equals y, then 1, else 0. Vectorizes.",">>\ndyad\nIf x is greater than y, then 1, else 0.","^^\ndyad\nBitwise XOR.\n\nœ^\ndyad\nMultiset symmetric difference.","__\ndyad\nSubtraction.","aa\ndyad\nLogical AND. Vectorizes with depth 0.\n\nØa\nnilad\nAlphabet; yield 'abcdefghijklmnopqrstuvwxyz'.","bb\ndyad\nConvert from integer to base y.\n\nØb\nnilad\nBase64 digits; yield 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/'","cc\ndyad\nCombinations; compute xCy.\n\nØc\nnilad\nVowels; yield 'AEIOUaeiou'.\n\nÆc\nmonad\nCarmichael function.\n\næc\ndyad\nConvolution of x and y.\n\nŒc\nmonad\nUnordered pairs (œc2).\n\nœc\ndyad\nCombinations without replacement.","dd\ndyad\nDivmod.\n\nÆd\nmonad\nDivisor count.","ee\ndyad\nIf x occurs in y, then 1, else 0.\n\nØe\nnilad\nEuler's number\n\nÆe\nmonad\nExponential function.","ff\ndyad\nFilter; remove the elements from x that are not in y.\n\nÆf\nmonad\nCompute the array of primes whose product is z.\n\nÐf\nQuick\nFilter. Keep all items that satisfy a condition.\nÐf","gg\ndyad\nGreatest common divisor (GCD, HCF).\n\nŒg\nmonad\nGroup runs of equal elements.","hØh\nnilad\nHexadecimal digits; yield '0123456789abcdef'.","ii\ndyad\nFind the first index of element y in list x, or 0.\n\nÆi\nmonad\nSeparate a number z into [real(z), imag(z)].\n\næi\ndyad\nModular inverse of x, modulo y, or if none exists, 0.","jj\ndyad\nJoin list x with separator y.","ll\ndyad\nLogarithm with base y.\n\nÆl\nmonad\nNatural logarithm.\n\næl\ndyad\nLowest common multiple (LCM).\n\nŒl\nmonad\nLower case.\n\nœl\ndyad\nTrim all elements of y from the left side of x.","mm\ndyad\nModular; return every y th element of x. If y is zero, mirror: prepend x to its reverse.\n\nÆm\nmonad\nArithmetic mean.","nn\ndyad\nNot equals. If x equals y, then 0, else 1. Vectorizes.\n\nÆn\nmonad\nNext; generate the closest prime strictly greater than z.","oo\ndyad\nLogical OR. Vectorizes with depth 0.","pp\ndyad\nCartesian product.\n\nØp\nnilad\nPhi (golden ratio)\n\nÆp\nmonad\nPrevious; generate the closest prime strictly less than z.\n\næp\ndyad\nPrecision; round x to y significant figures.\n\nŒp\nmonad\nCartesian product of z's items.\n\nœp\ndyad\nPartition y at all truthy indices of x, without keeping the borders.","qØq\nnilad\nQwerty; yield ['qwertyuiop', 'asdfghjkl', 'zxcvbnm'].","rr\ndyad\nInclusive range. Descending if x > y.\n\nÆr\nmonad\nFind the roots of a polynomial, given a list of coefficients.\n\nær\ndyad\nRound x to the nearest multiple of 10−y.\n\nŒr\nmonad\nRun-length encode. “aab”Œr is [['a', 2], ['b', 1]].\n\nœr\ndyad\nTrim all elements of y from the right side of x.","ss\ndyad\nSplit x into slices of length y.\n\nÆs\nmonad\nDivisor sum.\n\nŒs\nmonad\nSwap case.\n\nœs\ndyad\nSplit x into y chunks of similar lengths.","tt\ndyad\nTrim all elements of y from both sides of x.\n\nŒt\nmonad\nTitle case.","uŒu\nmonad\nUpper case.","vv\ndyad\nEval x as Jelly code, with argument y.\n\nØv\nnilad\nYield 'Ṙv'.\n\nÆv\nmonad\nCount distinct prime factors.","ww\ndyad\nFind the first index of sublist y within list x, or 0.","xx\ndyad\nTimes; repeat the elements of x y times.","yy\ndyad\nTranslate the elements of y according to the mapping in x.\n\nØy\nnilad\nVowels; yield 'AEIOUYaeiouy'.","zz\ndyad\nZip; transpose x with filler y.","||\ndyad\nBitwise OR.\n\nœ|\ndyad\nMultiset union.","⁼⁼\ndyad\nEquals. Does not vectorize.","⁻⁻\ndyad\nNot equals. Does not vectorize.","ạạ\ndyad\nAbsolute difference.","ḅḅ\ndyad\nConvert from base y to integer.","ḍḍ\ndyad\nIf x divides y, then 1, else 0.\n\nÆḍ\nmonad\nProper divisor count.","ẹẹ\ndyad\nReturn the indices of all occurrences of y in x.","ịị\ndyad\nReturn the element of y at index x % len(y). If floor(x) and ceil(x) aren't equal, return the elements of y at indices floor(x) % len(y) and ceil(x) % len(y).\n\nÆị\nmonad\nCombines the first two elements of a list into a complex number, z[0] + 1j*z[1]. Missing values are replaced with zeroes and extra values are truncated.\n\næị\ndyad\nCombines x and y into a complex number as x + 1j*y.\n\nœị\ndyad\nElement of y at multi-dimensional index x. If x is empty, return y. Otherwise, y is replaced by its element at index x[0] (behaves like ị), x is replaced by x[1:], and the procedure is repeated.","ḷḷ\ndyad\nLeft argument; return x.","ṃṃ\ndyad\nBase decompression; convert x to base length(y) then index into y.\n\nÆṃ\nmonad\nMode. Vectorizes.","ọọ\ndyad\nOrder, multiplicity, valuation; how many times is x divisible by y?","ṛṛ\ndyad\nRight argument; return y.\n\nÆṛ\nmonad\nConstruct the polynomial with roots z. Returns list of coefficients.","ṣṣ\ndyad\nSplit list x at occurrences of y.\n\nÆṣ\nmonad\nProper divisor sum.\n\nœṣ\ndyad\nSplit x around sublists equal to y.","ṭṭ\ndyad\nTack; append x to y.","ȧȧ\ndyad\nLogical AND. Does not vectorize.","ḃḃ\ndyad\nConvert from integer to bijective base y.","ċċ\ndyad\nCount the occurrences of y in x.\n\næċ\ndyad\nCeil x to the nearest power of y.\n\nŒċ\nmonad\nUnordered pairs with replacement (œċ2).\n\nœċ\ndyad\nCombinations with replacement.","ḟḟ\ndyad\nFilter; remove the elements from x that are in y.\n\næḟ\ndyad\nFloor x to the nearest power of y.\n\nÐḟ\nQuick\nFilter. Discard all items that satisfy a condition.\nÐḟ","ḣḣ\ndyad\nHead; return x[:y].","ṁṁ\ndyad\nMold; reshape the content of x like the content of y. Reuses the content of x if necessary.\n\nÆṁ\nmonad\nMedian. Vectorizes.","ȯȯ\ndyad\nLogical OR. Does not vectorize.","ṗṗ\ndyad\nCartesian power.\n\nŒṗ\nmonad\nInteger partitions of z (ways to sum positive integers to z)\n\nœṗ\ndyad\nPartition y at all truthy indices of x.","ṙṙ\ndyad\nRotate x y units to the left.\n\nŒṙ\nmonad\nRun-length decode. Right inverse of Œr.","ṡṡ\ndyad\nReturn all (overlapping) slices of length y of x.\n\nœṡ\ndyad\nSplit x at the first occurrence of y.","ṫṫ\ndyad\nTail; return x[y - 1:].","ẋẋ\ndyad\nRepeat list x y times.","ẇẇ\ndyad\nSublist exists; return 1 if x is a contiguous sublist of y, else 0.","żż\ndyad\nZip; interleave x and y.","««\ndyad\nMinimum of x and y.\n\næ«\ndyad\nBit shift; compute x × 2y.","»»\ndyad\nMaximum of x and y.\n\næ»\ndyad\nBit shift; compute x × 2−y. Returns an integer."," \nSYNTAX\nToken separator.","©©\nQuick\nCopy link result to register (® atom to retrieve).\n©","ßß\nQuick\nThis link, with the same arity.\nß","¢¢\nQuick\nLast link as a nilad.\n¢","ÇÇ\nQuick\nLast link as a monad.\nÇ","çç\nQuick\nLast link as a dyad.\nç","ÑÑ\nQuick\nNext link as a monad.\nÑ","ññ\nQuick\nNext link as a dyad.\nñ","££\nQuick\nLink at index n as a nilad.\n£","ĿĿ\nQuick\nLink at index n as a monad.\nĿ\n\nÆĿ\nmonad\nReturns the zth Lucas number\n\nÐĿ\nQuick\nLike ÐL. Collects all intermediate results.","ŀŀ\nQuick\nLink at index n as a dyad.\nŀ","¦¦\nQuick\nApply link to items at specific indices.\n¦","¡¡\nQuick\nRepeat n times.\n¡\n\nÆ¡\nmonad\nConvert from factorial base to integer.\n\nС\nQuick\nLike ¡. Collects all intermediate results.","¿¿\nQuick\nWhile loop.\n¿\n\nÆ¿\nmonad\nConvert from primorial base to integer.\n\nŒ¿\nmonad\nIndex of permutation z in a lexicographically sorted list of all permutations of z's items.\n\nœ¿\ndyad\nIndex of permutation x in a list of all permutations of x's items sorted by their index in y.\n\nп\nQuick\nLike ¿. Collects all intermediate results.","//\nQuick\nReduce or n-wise reduce.\n/ or /","\\\\\nQuick\nCumulative reduce or n-wise overlapping reduce.\n\\ or \\","¤¤\nQuick\nNilad followed by links as a nilad.","$$\nQuick\nLast two links (if not part of an LCC) as a monad","ƊƊ\nQuick\nLast three links (if not part of an LCC) as a monad","ƲƲ\nQuick\nLast four links (if not part of an LCC) as a monad","¥¥\nQuick\nLast two links (if not part of an LCC) as a dyad","ɗɗ\nQuick\nLast three links (if not part of an LCC) as a dyad","ʋʋ\nQuick\nLast four links (if not part of an LCC) as a dyad","##\nQuick\nnfind: Count up, collecting first n matches.\n#","??\nQuick\nTernary if.\n?\n\nÆ?\nmonad\nConvert from integer to primorial base.\n\nŒ?\nmonad\nShortest permutation of items [1,2,...,N] which would yield z via Œ¿.\n\nœ?\ndyad\nPermutation at index x of the items in y (where y defines the sort order of those items).","⁺⁺\nQuick\nDuplicates the previous link.","@@\nQuick\nSwaps operands.\n@","``\nQuick\nMake a monad from a dyad by repeating the argument.\n`","\"\"\nQuick\nVectorize/zipwith.\n\"","''\nQuick\nFor monads, flat. For dyad, spawn.\n'","þþ\nQuick\nOuter product/table.\nþ","{{\nQuick\nTurn a monad into a dyad. Uses the left argument.\n{","}}\nQuick\nTurn a monad into a dyad. Uses the right argument.\n}","€€\nQuick\nEach. Map a link over its left argument.\n€\n\nЀ\nQuick\nEach. Map a link over its right argument.\nЀ","ÞÞ\nQuick\nSort by some key function.\nÞ","ƝƝ\nQuick\nApply a dyadic link or a monadic chain for all pairs of neighboring elements.\nƝ","ƤƤ\nQuick\nMap a link over prefixes, and if given a , overlapping infixes if positive, or the overlapping outfixes of abs() if negative.\nƤ or Ƥ\n\nÐƤ\nQuick\nMap a link over suffixes, and if given a , non-overlapping infixes if positive, or the non-overlapping outfixes of abs() if negative.\nÐƤ or ÐƤ","ƙƙ\nQuick\nKey. Map a link over the groups formed by identical items.\nƙ","ƭƭ\nQuick\nTie. Cycle through a number of links each time called."," \nSYNTAX\nToken separator.","00\nSYNTAX\nThe literal 0.","11\nSYNTAX\nThe literal 1.","22\nSYNTAX\nThe literal 2.","33\nSYNTAX\nThe literal 3.","44\nSYNTAX\nThe literal 4.","55\nSYNTAX\nThe literal 5.","66\nSYNTAX\nThe literal 6.","77\nSYNTAX\nThe literal 7.","88\nSYNTAX\nThe literal 8.","99\nSYNTAX\nThe literal 9.","““\nSYNTAX\nBegins a string literal, and separates a list of strings inside a string literal. “12“34”","””\nSYNTAX\nTerminates a regular string or a list of strings. Without “, a character literal. “1234”","»»\nSYNTAX\nTerminates a dictionary-compressed string. “1234»","‘‘\nSYNTAX\nTerminates a code-page index list. Jelly's version of ord(). “12“34‘","’’\nSYNTAX\nTerminates a base-250 number. “1234’","⁾⁾\nSYNTAX\nBegins a 2-char string literal. ⁾12","⁽⁽\nSYNTAX\nBegins a 2-digit base-250 number. If the number is larger than 31500, subtracts 62850, otherwise adds 750.⁽12","¶¶\nSYNTAX\nStarts a new link ","øø\nSYNTAX\nStarts a separate niladic chain. ø","µµ\nSYNTAX\nStarts a separate monadic chain. µ","ðð\nSYNTAX\nStarts a separate dyadic chain. ð","ɓɓ\nSYNTAX\nStarts a separate dyadic chain with reversed arguments. ɓ","ıı\nSYNTAX\nComplex number. Without arguments, 1j. xıy","ȷȷ\nSYNTAX\nDecimal number, as in 2e6 for 2000000. Without arguments, 1000. xȷy","--\nSYNTAX\nNegative number. Without arguments, -1. -5\n\nœ-\ndyad\nMultiset difference.","..\nSYNTAX\nDecimal number. Without arguments, 0.5. 1.2\n\næ.\ndyad\nDot product of two vectors (real/complex).",",,\nSYNTAX\nSeparate elements of a list. If any of the arguments is not a literal, or spaces separate the arguments, , will be treated as the \"pair\" atom instead. x,y","[[\nSYNTAX\nBegins a comma-separated list. [2]","]]\nSYNTAX\nEnds a comma-separated list. [2]"," \nSYNTAX\nToken separator.","ØØ\nSYNTAX\nBegins two-byte atom.","ÆÆ\nSYNTAX\nBegins two-byte atom.","ææ\nSYNTAX\nBegins two-byte atom.","ŒŒ\nSYNTAX\nBegins two-byte atom.","œœ\nSYNTAX\nBegins two-byte atom.","ÐÐ\nSYNTAX\nBegins two-byte Quick."] -,bqk=''.replace(/∙/g,'') -,bqv=''.replace(/∙/g,'') -,tc={},bqc={} //tab completions and ` completions -for(let i=0;i') - for(let j=0;j'+lbs[i][0]+'' -} -let d=document,el=d.createElement('div');el.innerHTML= -`
${lbh}
- +; (_ => { + let hc = { '<': '<', '&': '&', "'": ''', '"': '"' }, he = x => x.replace(/[<&'"]/g, c => hc[c]) //html chars and escape fn + , tcs = "v!¡|c¢-L£^o¤=Y¥^|¦oC©^_¬oR®^uµ/2½v?¿CE€AEÆC,Ç-DÐ~NÑ^*×/OØOEŒ|PÞ^Sßaeæc,ç^dð^iı^jȷ~nñ^/÷/oøoeœ|pþ\\n¶^0°^1¹^2²^3³^4⁴^5⁵^6⁶^7⁷^8⁸^9⁹^+⁺^-⁻^=⁼^(⁽^)⁾`BƁC'Ƈ`DƊ,FƑG'ƓK'ƘM,Ɱ,NƝ`PƤ`TƬ`UƲZ,Ȥ`bɓc'ƈd'ɗ,fƒg'ɠh'ɦk'ƙm,ɱ,nɲp'ƥq'ʠ,rɼ,sʂt'ƭ`uʋz,ȥ.AẠ.BḄ.DḌ.EẸ.HḤ.IỊ.KḲ.LḶ.MṂ.NṆ.OỌ.RṚ.SṢ.TṬ.U§.VÄ.WẈ.YỴ.ZẒA.ȦB.ḂC.ĊD.ḊE.ĖF.ḞG.ĠH.ḢI.İL.ĿM.ṀN.ṄO.ȮP.ṖR.ṘS.ṠT.ṪW.ẆX.ẊY.ẎZ.Ż.aạ.bḅ.dḍ.eẹ.hḥ.iị.kḳ.lḷ.mṃ.nṇ.oọ.rṛ.sṣ.tṭ.u§.vÄ.wẉ.yỵ.zẓa.ȧb.ḃc.ċd.ḋe.ėf.ḟg.ġh.ḣl.ŀm.ṁn.ṅo.ȯp.ṗr.ṙs.ṡt.ṫw.ẇx.ẋy.ẏz.ż<<«>>»^'‘^,’^\"“\"\"”" + , lbs = ["®®\nnilad\nRestore; retrieve the value of the register. Initially 0.", "³³\nnilad\nReturn the third command line argument (first input) or 100.", "⁴⁴\nnilad\nReturn the fourth command line argument (second input) or 16.", "⁵⁵\nnilad\nReturn the fifth command line argument (third input) or 10.", "⁶⁶\nnilad\nReturn the sixth command line argument (fourth input) or ' '.", "⁷⁷\nnilad\nReturn the seventh command line argument (fifth input) or '\\n'.", "⁸⁸\nnilad\nReturn the link's left argument or [].", "⁹⁹\nnilad\nReturn the link's right argument or 256.", "ƓƓ\nnilad\nRead and evaluate a single line from STDIN.", "ƈƈ\nnilad\nRead a single character from STDIN.", "ɠɠ\nnilad\nRead a single line from STDIN.", " \nSYNTAX\nToken separator.", "¬¬\nmonad\nLogical NOT: if z is zero or empty, then 1, else 0.", "½½\nmonad\nSquare root.\n\nƽ\nmonad\nCompute the integer square root of z.", "!!\nmonad\nFactorial or Pi function.\n\nÆ!\nmonad\nConvert from integer to factorial base.\n\nŒ!\nmonad\nAll permutations of z. May contain duplicates.", "AA\nmonad\nAbsolute value.\n\nØA\nnilad\nAlphabet; yield 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'.\n\nÆA\nmonad\nArccosine.\n\næA\ndyad\nArctangent with two arguments, i.e., atan2().", "BB\nmonad\nConvert from integer to binary.\n\nØB\nnilad\nBase digits; yield '0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz'.\n\nŒB\nmonad\nBounce; yield z[:-1] + z[::-1]. Vectorizes at depth 1.", "CC\nmonad\nComplement; compute 1 − z.\n\nØC\nnilad\nConsonants; yield 'BCDFGHJKLMNPQRSTVWXYZbcdfghjklmnpqrstvwxyz'.\n\nÆC\nmonad\nCount the primes less or equal to z.", "DD\nmonad\nConvert from integer to decimal.\n\nØD\nnilad\nDigits; yield '0123456789'.\n\nÆD\nmonad\nCompute the array of z's divisors.\n\nŒD\nmonad\nDiagonals of a matrix. Starts with the main diagonal.", "EE\nmonad\nCheck if all elements of z are equal.\n\nÆE\nmonad\nCompute the array of exponents of z's prime factorization. Includes zero exponents.", "FF\nmonad\nFlatten list.\n\nÆF\nmonad\nCompute z's prime factorization as [prime, exponent] pairs.", "GG\nmonad\nAttempt to format z as a grid.\n\nŒG\nmonad\nGET request z. http:// is prepended by default.", "HH\nmonad\nHalve; compute z ÷ 2.\n\nØH\nnilad\nHexadecimal digits; yield '0123456789ABCDEF'.", "II\nmonad\nIncrements; compute the differences of consecutive elements of z.", "JJ\nmonad\nReturns [1 … len(z)].\n\nØJ\nnilad\nYield Jelly's codepage.", "KK\nmonad\nJoin z, separating by spaces.", "LL\nmonad\nLength.\n\nÐL\nQuick\nLoop. Repeat until the results are no longer unique.\nÐL", "MM\nmonad\nReturn all indices of z that correspond to maximal elements.", "NN\nmonad\nNegative; compute −z.\n\nÆN\nmonad\nGenerate the zth prime.", "OO\nmonad\nOrd; cast to number.", "PP\nmonad\nProduct of a list.\n\nØP\nnilad\nPi\n\nÆP\nmonad\nIf z is a prime, then 1, else 0.\n\nŒP\nmonad\nPowerset of z. May contain duplicates.", "QQ\nmonad\nReturn the unique elements of z, sorted by first appearance.\n\nØQ\nnilad\nQwerty; yield ['QWERTYUIOP', 'ASDFGHJKL', 'ZXCVBNM'].\n\nŒQ\nmonad\nDistinct sieve.", "RR\nmonad\nInclusive range [1 … z].\n\nÆR\nmonad\nRange; generate all primes between 2 and z.\n\næR\ndyad\nInclusive prime range, from x to y.\n\nŒR\nmonad\nList from −abs(z) to abs(z) inclusive (shorthand for Ar@N$).", "SS\nmonad\nSum of a list.\n\nÆS\nmonad\nSine.\n\nœS\ndyad\nAfter sleeping for y seconds, return x.", "TT\nmonad\nReturn all indices of z that correspond to truthy elements.\n\nÆT\nmonad\nTangent.\n\nŒT\nmonad\nFormat time: Let the last three bits of z be abc. If a is 1, include the time; if b is 1, include the minute; if c is 1, include the second.", "UU\nmonad\nUpend; reverse an array.", "VV\nmonad\nEval z as Jelly code, with no arguments. If z is a list, it maps Python's str function to all of z's elements, concatenates them and then eval's the result. Vectorizes at depth 1.\n\nØV\nnilad\nYield 'ṘV' (a cheat for writing a quine\n\nŒV\nmonad\nEvaluate Python code z.", "WW\nmonad\nWrap; return [z].\n\nØW\nnilad\nWord; yield 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789_'", "XX\nmonad\nRandom; choose a random item from z if z is a list, or from 1 to z inclusive if z is a positive integer. If z = 0, return z. Error if z is negative or a decimal.", "YY\nmonad\nJoin z, separating by linefeeds.\n\nØY\nnilad\nConsonants; yield 'BCDFGHJKLMNPQRSTVWXZbcdfghjklmnpqrstvwxz'.", "ZZ\nmonad\nZip; push the array of all columns of z.", "~~\nmonad\nBitwise NOT.", "°°\nmonad\nConvert z from degrees to radians.\n\nÆ°\nmonad\nConvert z from radians to degrees.", "¹¹\nmonad\nIdentity; return z.", "²²\nmonad\nSquare.\n\nƲ\nmonad\nIf z is a square, then 1, else 0.", "ẠẠ\nmonad\nAll; return 0 if z contains a falsey value, else 1.\n\nÆẠ\nmonad\nCosine.", "ḄḄ\nmonad\nConvert from binary to integer.\n\nŒḄ\nmonad\nBounce; yield z[:-1] + z[::-1]. Does not vectorize.", "ḌḌ\nmonad\nConvert from decimal to integer.\n\nÆḌ\nmonad\nProper divisors.\n\nŒḌ\nmonad\nReconstruct matrix from its diagonals.", "ẸẸ\nmonad\nAny; return 1 if z contains a truthy value, else 0.\n\nÆẸ\nmonad\nInverse of ÆE.", "ḤḤ\nmonad\nDouble; compute 2z.", "ỊỊ\nmonad\nInsignificant; return abs(z) ≤ 1.", "ḲḲ\nmonad\nSplit z at spaces.", "ḶḶ\nmonad\nLowered range; return [0 … z−1].\n\nÐḶ\nQuick\nLike ÐL. Collects all results in the loop.", "ṂṂ\nmonad\nMinimum.\n\nÐṂ\nQuick\nKeep elements with minimal link value; [e for e in z if link(e) == min(map(link, z))].\nÐṂ", "ṆṆ\nmonad\nLogical NOT. Does not vectorize.", "ỌỌ\nmonad\nChr; cast to character.", "ṚṚ\nmonad\nReverse z. Does not vectorize.", "ṢṢ\nmonad\nSort the list z.\n\nÆṢ\nmonad\nArcsine.", "ṬṬ\nmonad\nReturn a Boolean array with 1's at the indices in z.\n\nÆṬ\nmonad\nArctangent.", "§§\nmonad\nGrade the list z up, i.e., sort its indices by their values.", "ÄÄ\nmonad\nUneval; right inverse of V.", "ỴỴ\nmonad\nSplit z at linefeeds.", "ȦȦ\nmonad\nAny and all; return 0 if z is empty, or contains a falsey value when flattened, else 1.", "ḂḂ\nmonad\nBit; return z % 2.\n\nŒḂ\nmonad\nCheck if z is a palindrome. For integers, short for DŒḂ$.", "ĊĊ\nmonad\nCeil; round z up to the nearest integer. Imag. part for complex z.\n\nÆĊ\nmonad\nReturns the zth Catalan number", "ḊḊ\nmonad\nDequeue; return z[1:].\n\nÆḊ\nmonad\nDeterminant. For non-square z, computes det(zzT)½; if z is a row vector, this is its norm.\n\nŒḊ\nmonad\nDepth.", "ĖĖ\nmonad\nEnumerate; return [ [1,y[1]] , [2,y[2]], ... ].", "ḞḞ\nmonad\nFloor; round z down to the nearest integer. Real part for complex z.\n\nÆḞ\nmonad\nReturns the zth item in the Fibonacci sequence.", "ĠĠ\nmonad\nGroup the indices of z by their corresponding values.", "ḢḢ\nmonad\nHead; pop and return the first element of z. Modifies z.", "İİ\nmonad\nInverse; compute 1 ÷ z.", "ṀṀ\nmonad\nMaximum.\n\nÐṀ\nQuick\nKeep elements with maximal link value; [e for e in z if link(e) == max(map(link, z))].\nÐṀ", "ṄṄ\nmonad\nPrint z and a linefeed. Returns z.", "ȮȮ\nmonad\nPrint z. Returns z.", "ṖṖ\nmonad\nPop; return z[:-1].\n\nØṖ\nnilad\nYield the set of printable ASCII chars.\n\nŒṖ\nmonad\nPartition of z (z must be a list).", "ṘṘ\nmonad\nPrint a string representation of z, without a linefeed. Returns z.\n\nŒṘ\nmonad\nPython's string representation.", "ṠṠ\nmonad\nSign of z. Conjugate for complex z.", "ṪṪ\nmonad\nTail; pop and return the last element of z. Modifies z.\n\nÆṪ\nmonad\nTotient function.", "ẆẆ\nmonad\nSublists; all non-empty contiguous slices of z.", "ẊẊ\nmonad\nShuffle; return a random permutation of z.", "ẎẎ\nmonad\nTighten; dump all lists inside z.", "‘‘\nmonad\nIncrement; compute z + 1.", "’’\nmonad\nDecrement; compute z − 1.", " \nSYNTAX\nToken separator.", "××\ndyad\nMultiplication.\n\næ×\ndyad\nMatrix multiplication.", "÷÷\ndyad\nFloating point division.", "%%\ndyad\nModulus.\n\næ%\ndyad\nSymmetric modulo 2y; map x in the interval (−y, y]. Try 100Ræ%4 to get the hang of it.", "&&\ndyad\nBitwise AND.\n\nœ&\ndyad\nMultiset intersection.", "**\ndyad\nExponentiation with base x.\n\næ*\ndyad\nMatrix power.", "++\ndyad\nAddition.", ",,\ndyad\nPair; return [x, y].", "::\ndyad\nInteger division.", ";;\ndyad\nConcatenate.", "<<\ndyad\nIf x is less than y, then 1, else 0.", "==\ndyad\nIf x equals y, then 1, else 0. Vectorizes.", ">>\ndyad\nIf x is greater than y, then 1, else 0.", "^^\ndyad\nBitwise XOR.\n\nœ^\ndyad\nMultiset symmetric difference.", "__\ndyad\nSubtraction.", "aa\ndyad\nLogical AND. Vectorizes with depth 0.\n\nØa\nnilad\nAlphabet; yield 'abcdefghijklmnopqrstuvwxyz'.", "bb\ndyad\nConvert from integer to base y.\n\nØb\nnilad\nBase64 digits; yield 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/'", "cc\ndyad\nCombinations; compute xCy.\n\nØc\nnilad\nVowels; yield 'AEIOUaeiou'.\n\nÆc\nmonad\nCarmichael function.\n\næc\ndyad\nConvolution of x and y.\n\nŒc\nmonad\nUnordered pairs (œc2).\n\nœc\ndyad\nCombinations without replacement.", "dd\ndyad\nDivmod.\n\nÆd\nmonad\nDivisor count.", "ee\ndyad\nIf x occurs in y, then 1, else 0.\n\nØe\nnilad\nEuler's number\n\nÆe\nmonad\nExponential function.", "ff\ndyad\nFilter; remove the elements from x that are not in y.\n\nÆf\nmonad\nCompute the array of primes whose product is z.\n\nÐf\nQuick\nFilter. Keep all items that satisfy a condition.\nÐf", "gg\ndyad\nGreatest common divisor (GCD, HCF).\n\nŒg\nmonad\nGroup runs of equal elements.", "hØh\nnilad\nHexadecimal digits; yield '0123456789abcdef'.", "ii\ndyad\nFind the first index of element y in list x, or 0.\n\nÆi\nmonad\nSeparate a number z into [real(z), imag(z)].\n\næi\ndyad\nModular inverse of x, modulo y, or if none exists, 0.", "jj\ndyad\nJoin list x with separator y.", "ll\ndyad\nLogarithm with base y.\n\nÆl\nmonad\nNatural logarithm.\n\næl\ndyad\nLowest common multiple (LCM).\n\nŒl\nmonad\nLower case.\n\nœl\ndyad\nTrim all elements of y from the left side of x.", "mm\ndyad\nModular; return every y th element of x. If y is zero, mirror: prepend x to its reverse.\n\nÆm\nmonad\nArithmetic mean.", "nn\ndyad\nNot equals. If x equals y, then 0, else 1. Vectorizes.\n\nÆn\nmonad\nNext; generate the closest prime strictly greater than z.", "oo\ndyad\nLogical OR. Vectorizes with depth 0.", "pp\ndyad\nCartesian product.\n\nØp\nnilad\nPhi (golden ratio)\n\nÆp\nmonad\nPrevious; generate the closest prime strictly less than z.\n\næp\ndyad\nPrecision; round x to y significant figures.\n\nŒp\nmonad\nCartesian product of z's items.\n\nœp\ndyad\nPartition y at all truthy indices of x, without keeping the borders.", "qØq\nnilad\nQwerty; yield ['qwertyuiop', 'asdfghjkl', 'zxcvbnm'].", "rr\ndyad\nInclusive range. Descending if x > y.\n\nÆr\nmonad\nFind the roots of a polynomial, given a list of coefficients.\n\nær\ndyad\nRound x to the nearest multiple of 10−y.\n\nŒr\nmonad\nRun-length encode. “aab”Œr is [['a', 2], ['b', 1]].\n\nœr\ndyad\nTrim all elements of y from the right side of x.", "ss\ndyad\nSplit x into slices of length y.\n\nÆs\nmonad\nDivisor sum.\n\nŒs\nmonad\nSwap case.\n\nœs\ndyad\nSplit x into y chunks of similar lengths.", "tt\ndyad\nTrim all elements of y from both sides of x.\n\nŒt\nmonad\nTitle case.", "uŒu\nmonad\nUpper case.", "vv\ndyad\nEval x as Jelly code, with argument y.\n\nØv\nnilad\nYield 'Ṙv'.\n\nÆv\nmonad\nCount distinct prime factors.", "ww\ndyad\nFind the first index of sublist y within list x, or 0.", "xx\ndyad\nTimes; repeat the elements of x y times.", "yy\ndyad\nTranslate the elements of y according to the mapping in x.\n\nØy\nnilad\nVowels; yield 'AEIOUYaeiouy'.", "zz\ndyad\nZip; transpose x with filler y.", "||\ndyad\nBitwise OR.\n\nœ|\ndyad\nMultiset union.", "⁼⁼\ndyad\nEquals. Does not vectorize.", "⁻⁻\ndyad\nNot equals. Does not vectorize.", "ạạ\ndyad\nAbsolute difference.", "ḅḅ\ndyad\nConvert from base y to integer.", "ḍḍ\ndyad\nIf x divides y, then 1, else 0.\n\nÆḍ\nmonad\nProper divisor count.", "ẹẹ\ndyad\nReturn the indices of all occurrences of y in x.", "ịị\ndyad\nReturn the element of y at index x % len(y). If floor(x) and ceil(x) aren't equal, return the elements of y at indices floor(x) % len(y) and ceil(x) % len(y).\n\nÆị\nmonad\nCombines the first two elements of a list into a complex number, z[0] + 1j*z[1]. Missing values are replaced with zeroes and extra values are truncated.\n\næị\ndyad\nCombines x and y into a complex number as x + 1j*y.\n\nœị\ndyad\nElement of y at multi-dimensional index x. If x is empty, return y. Otherwise, y is replaced by its element at index x[0] (behaves like ị), x is replaced by x[1:], and the procedure is repeated.", "ḷḷ\ndyad\nLeft argument; return x.", "ṃṃ\ndyad\nBase decompression; convert x to base length(y) then index into y.\n\nÆṃ\nmonad\nMode. Vectorizes.", "ọọ\ndyad\nOrder, multiplicity, valuation; how many times is x divisible by y?", "ṛṛ\ndyad\nRight argument; return y.\n\nÆṛ\nmonad\nConstruct the polynomial with roots z. Returns list of coefficients.", "ṣṣ\ndyad\nSplit list x at occurrences of y.\n\nÆṣ\nmonad\nProper divisor sum.\n\nœṣ\ndyad\nSplit x around sublists equal to y.", "ṭṭ\ndyad\nTack; append x to y.", "ȧȧ\ndyad\nLogical AND. Does not vectorize.", "ḃḃ\ndyad\nConvert from integer to bijective base y.", "ċċ\ndyad\nCount the occurrences of y in x.\n\næċ\ndyad\nCeil x to the nearest power of y.\n\nŒċ\nmonad\nUnordered pairs with replacement (œċ2).\n\nœċ\ndyad\nCombinations with replacement.", "ḟḟ\ndyad\nFilter; remove the elements from x that are in y.\n\næḟ\ndyad\nFloor x to the nearest power of y.\n\nÐḟ\nQuick\nFilter. Discard all items that satisfy a condition.\nÐḟ", "ḣḣ\ndyad\nHead; return x[:y].", "ṁṁ\ndyad\nMold; reshape the content of x like the content of y. Reuses the content of x if necessary.\n\nÆṁ\nmonad\nMedian. Vectorizes.", "ȯȯ\ndyad\nLogical OR. Does not vectorize.", "ṗṗ\ndyad\nCartesian power.\n\nŒṗ\nmonad\nInteger partitions of z (ways to sum positive integers to z)\n\nœṗ\ndyad\nPartition y at all truthy indices of x.", "ṙṙ\ndyad\nRotate x y units to the left.\n\nŒṙ\nmonad\nRun-length decode. Right inverse of Œr.", "ṡṡ\ndyad\nReturn all (overlapping) slices of length y of x.\n\nœṡ\ndyad\nSplit x at the first occurrence of y.", "ṫṫ\ndyad\nTail; return x[y - 1:].", "ẋẋ\ndyad\nRepeat list x y times.", "ẇẇ\ndyad\nSublist exists; return 1 if x is a contiguous sublist of y, else 0.", "żż\ndyad\nZip; interleave x and y.", "««\ndyad\nMinimum of x and y.\n\næ«\ndyad\nBit shift; compute x × 2y.", "»»\ndyad\nMaximum of x and y.\n\næ»\ndyad\nBit shift; compute x × 2−y. Returns an integer.", " \nSYNTAX\nToken separator.", "©©\nQuick\nCopy link result to register (® atom to retrieve).\n©", "ßß\nQuick\nThis link, with the same arity.\nß", "¢¢\nQuick\nLast link as a nilad.\n¢", "ÇÇ\nQuick\nLast link as a monad.\nÇ", "çç\nQuick\nLast link as a dyad.\nç", "ÑÑ\nQuick\nNext link as a monad.\nÑ", "ññ\nQuick\nNext link as a dyad.\nñ", "££\nQuick\nLink at index n as a nilad.\n£", "ĿĿ\nQuick\nLink at index n as a monad.\nĿ\n\nÆĿ\nmonad\nReturns the zth Lucas number\n\nÐĿ\nQuick\nLike ÐL. Collects all intermediate results.", "ŀŀ\nQuick\nLink at index n as a dyad.\nŀ", "¦¦\nQuick\nApply link to items at specific indices.\n¦", "¡¡\nQuick\nRepeat n times.\n¡\n\nÆ¡\nmonad\nConvert from factorial base to integer.\n\nС\nQuick\nLike ¡. Collects all intermediate results.", "¿¿\nQuick\nWhile loop.\n¿\n\nÆ¿\nmonad\nConvert from primorial base to integer.\n\nŒ¿\nmonad\nIndex of permutation z in a lexicographically sorted list of all permutations of z's items.\n\nœ¿\ndyad\nIndex of permutation x in a list of all permutations of x's items sorted by their index in y.\n\nп\nQuick\nLike ¿. Collects all intermediate results.", "//\nQuick\nReduce or n-wise reduce.\n/ or /", "\\\\\nQuick\nCumulative reduce or n-wise overlapping reduce.\n\\ or \\", "¤¤\nQuick\nNilad followed by links as a nilad.", "$$\nQuick\nLast two links (if not part of an LCC) as a monad", "ƊƊ\nQuick\nLast three links (if not part of an LCC) as a monad", "ƲƲ\nQuick\nLast four links (if not part of an LCC) as a monad", "¥¥\nQuick\nLast two links (if not part of an LCC) as a dyad", "ɗɗ\nQuick\nLast three links (if not part of an LCC) as a dyad", "ʋʋ\nQuick\nLast four links (if not part of an LCC) as a dyad", "##\nQuick\nnfind: Count up, collecting first n matches.\n#", "??\nQuick\nTernary if.\n?\n\nÆ?\nmonad\nConvert from integer to primorial base.\n\nŒ?\nmonad\nShortest permutation of items [1,2,...,N] which would yield z via Œ¿.\n\nœ?\ndyad\nPermutation at index x of the items in y (where y defines the sort order of those items).", "⁺⁺\nQuick\nDuplicates the previous link.", "@@\nQuick\nSwaps operands.\n@", "``\nQuick\nMake a monad from a dyad by repeating the argument.\n`", "\"\"\nQuick\nVectorize/zipwith.\n\"", "''\nQuick\nFor monads, flat. For dyad, spawn.\n'", "þþ\nQuick\nOuter product/table.\nþ", "{{\nQuick\nTurn a monad into a dyad. Uses the left argument.\n{", "}}\nQuick\nTurn a monad into a dyad. Uses the right argument.\n}", "€€\nQuick\nEach. Map a link over its left argument.\n€\n\nЀ\nQuick\nEach. Map a link over its right argument.\nЀ", "ÞÞ\nQuick\nSort by some key function.\nÞ", "ƝƝ\nQuick\nApply a dyadic link or a monadic chain for all pairs of neighboring elements.\nƝ", "ƤƤ\nQuick\nMap a link over prefixes, and if given a , overlapping infixes if positive, or the overlapping outfixes of abs() if negative.\nƤ or Ƥ\n\nÐƤ\nQuick\nMap a link over suffixes, and if given a , non-overlapping infixes if positive, or the non-overlapping outfixes of abs() if negative.\nÐƤ or ÐƤ", "ƙƙ\nQuick\nKey. Map a link over the groups formed by identical items.\nƙ", "ƭƭ\nQuick\nTie. Cycle through a number of links each time called.", " \nSYNTAX\nToken separator.", "00\nSYNTAX\nThe literal 0.", "11\nSYNTAX\nThe literal 1.", "22\nSYNTAX\nThe literal 2.", "33\nSYNTAX\nThe literal 3.", "44\nSYNTAX\nThe literal 4.", "55\nSYNTAX\nThe literal 5.", "66\nSYNTAX\nThe literal 6.", "77\nSYNTAX\nThe literal 7.", "88\nSYNTAX\nThe literal 8.", "99\nSYNTAX\nThe literal 9.", "““\nSYNTAX\nBegins a string literal, and separates a list of strings inside a string literal. “12“34”", "””\nSYNTAX\nTerminates a regular string or a list of strings. Without “, a character literal. “1234”", "»»\nSYNTAX\nTerminates a dictionary-compressed string. “1234»", "‘‘\nSYNTAX\nTerminates a code-page index list. Jelly's version of ord(). “12“34‘", "’’\nSYNTAX\nTerminates a base-250 number. “1234’", "⁾⁾\nSYNTAX\nBegins a 2-char string literal. ⁾12", "⁽⁽\nSYNTAX\nBegins a 2-digit base-250 number. If the number is larger than 31500, subtracts 62850, otherwise adds 750.⁽12", "¶¶\nSYNTAX\nStarts a new link ", "øø\nSYNTAX\nStarts a separate niladic chain. ø", "µµ\nSYNTAX\nStarts a separate monadic chain. µ", "ðð\nSYNTAX\nStarts a separate dyadic chain. ð", "ɓɓ\nSYNTAX\nStarts a separate dyadic chain with reversed arguments. ɓ", "ıı\nSYNTAX\nComplex number. Without arguments, 1j. xıy", "ȷȷ\nSYNTAX\nDecimal number, as in 2e6 for 2000000. Without arguments, 1000. xȷy", "--\nSYNTAX\nNegative number. Without arguments, -1. -5\n\nœ-\ndyad\nMultiset difference.", "..\nSYNTAX\nDecimal number. Without arguments, 0.5. 1.2\n\næ.\ndyad\nDot product of two vectors (real/complex).", ",,\nSYNTAX\nSeparate elements of a list. If any of the arguments is not a literal, or spaces separate the arguments, , will be treated as the \"pair\" atom instead. x,y", "[[\nSYNTAX\nBegins a comma-separated list. [2]", "]]\nSYNTAX\nEnds a comma-separated list. [2]", " \nSYNTAX\nToken separator.", "ØØ\nSYNTAX\nBegins two-byte atom.", "ÆÆ\nSYNTAX\nBegins two-byte atom.", "ææ\nSYNTAX\nBegins two-byte atom.", "ŒŒ\nSYNTAX\nBegins two-byte atom.", "œœ\nSYNTAX\nBegins two-byte atom.", "ÐÐ\nSYNTAX\nBegins two-byte Quick."] + , bqk = ''.replace(/∙/g, '') + , bqv = ''.replace(/∙/g, '') + , tc = {}, bqc = {} //tab completions and ` completions + for (let i = 0; i < bqk.length; i++)bqc[bqk[i]] = bqv[i] + for (let i = 0; i < tcs.length; i += 3)tc[tcs[i] + tcs[i + 1]] = tcs[i + 2] + for (let i = 0; i < tcs.length; i += 3) { let k = tcs[i + 1] + tcs[i]; tc[k] = tc[k] || tcs[i + 2] } + let lbh = ''; for (let i = 0; i < lbs.length; i++) { + let ks = [] + for (let j = 0; j < tcs.length; j += 3)if (lbs[i][0] === tcs[j + 2]) ks.push('\n' + tcs[j] + ' ' + tcs[j + 1] + ' ') + for (let j = 0; j < bqk.length; j++)if (lbs[i][0] === bqv[j]) ks.push('\n` ' + bqk[j]) + lbh += '' + lbs[i][0] + '' + } + let d = document, el = d.createElement('div'); el.innerHTML = + `
${lbh}
+ ` -d.body.appendChild(el) -let t,ts=[],lb=el.firstChild,bqm=0 //t:textarea or input, lb:language bar, bqm:backquote mode -let pd=x=>x.preventDefault() -let ev=(x,t,f,c)=>x.addEventListener(t,f,c) -ev(lb,'mousedown',x=>{ - if(x.target.classList.contains('ngn_x')){lb.hidden=1;upd();pd(x);return} - if(x.target.nodeName==='B'&&t){ - let i=t.selectionStart,j=t.selectionEnd,v=t.value,s=x.target.textContent - if(i!=null&&j!=null){t.value=v.slice(0,i)+s+v.slice(j);t.selectionStart=t.selectionEnd=i+s.length} - pd(x);return - } -}) -let fk=x=>{ - let t=x.target - if(bqm){let i=t.selectionStart,v=t.value,c=bqc[x.key];if(x.which>31){bqm=0;d.body.classList.remove('ngn_bq')} - if(c){t.value=v.slice(0,i)+c+v.slice(i);t.selectionStart=t.selectionEnd=i+1;pd(x);return!1}} - switch(x.ctrlKey+2*x.shiftKey+4*x.altKey+8*x.metaKey+100*x.which){ - case 900:{let i=t.selectionStart,v=t.value,c=tc[v.slice(i-2,i)] //tab - if(c){t.value=v.slice(0,i-2)+c+v.slice(i);t.selectionStart=t.selectionEnd=i-1;pd(x)} - break} - } -} -let ff=x=>{ - let t0=x.target,nn=t0.nodeName.toLowerCase() - if(nn!=='textarea'&&(nn!=='input'||t0.type!=='text'&&t0.type!=='search'))return - t=t0;if(!t.ngn){t.ngn=1;ts.push(t);ev(t,'keydown',fk)} -} -let upd=_=>{d.body.style.marginTop=lb.clientHeight+'px'} -upd();ev(window,'resize',upd) -ev(d,'focus',ff,!0);let ae=d.activeElement;ae&&ff({type:'focus',target:ae}) + d.body.appendChild(el) + let t, ts = [], lb = el.firstChild, bqm = 0 //t:textarea or input, lb:language bar, bqm:backquote mode + let pd = x => x.preventDefault() + let ev = (x, t, f, c) => x.addEventListener(t, f, c) + ev(lb, 'mousedown', x => { + if (x.target.classList.contains('ngn_x')) { lb.hidden = 1; upd(); pd(x); return } + if (x.target.nodeName === 'B' && t) { + let i = t.selectionStart, j = t.selectionEnd, v = t.value, s = x.target.textContent + if (i != null && j != null) { t.value = v.slice(0, i) + s + v.slice(j); t.selectionStart = t.selectionEnd = i + s.length } + pd(x); return + } + }) + let fk = x => { + let t = x.target + if (bqm) { + let i = t.selectionStart, v = t.value, c = bqc[x.key]; if (x.which > 31) { bqm = 0; d.body.classList.remove('ngn_bq') } + if (c) { t.value = v.slice(0, i) + c + v.slice(i); t.selectionStart = t.selectionEnd = i + 1; pd(x); return !1 } + } + switch (x.ctrlKey + 2 * x.shiftKey + 4 * x.altKey + 8 * x.metaKey + 100 * x.which) { + case 900: { + let i = t.selectionStart, v = t.value, c = tc[v.slice(i - 2, i)] //tab + if (c) { t.value = v.slice(0, i - 2) + c + v.slice(i); t.selectionStart = t.selectionEnd = i - 1; pd(x) } + break + } + } + } + let ff = x => { + let t0 = x.target, nn = t0.nodeName.toLowerCase() + if (nn !== 'textarea' && (nn !== 'input' || t0.type !== 'text' && t0.type !== 'search')) return + t = t0; if (!t.ngn) { t.ngn = 1; ts.push(t); ev(t, 'keydown', fk) } + } + let upd = _ => { d.body.style.marginTop = lb.clientHeight + 'px' } + upd(); ev(window, 'resize', upd) + ev(d, 'focus', ff, !0); let ae = d.activeElement; ae && ff({ type: 'focus', target: ae }) })(); diff --git a/lb.js b/lb.js index 17fa70e..cc325e9 100644 --- a/lb.js +++ b/lb.js @@ -1,74 +1,76 @@ -;(_=>{ -let hc={'<':'<','&':'&',"'":''','"':'"'},he=x=>x.replace(/[<&'"]/g,c=>hc[c]) //html chars and escape fn -,tcs='<-←xx×/\\×:-÷*O⍟[-⌹-]⌹OO○77⌈FF⌈ll⌊LL⌊T_⌶II⌶|_⊥TT⊤-|⊣|-⊢=/≠L-≠<=≤<_≤>=≥>_≥==≡=_≡7=≢L=≢vv∨^^∧^~⍲v~⍱^|↑v|↓((⊂cc⊂(_⊆c_⊆))⊃[|⌷|]⌷A|⍋V|⍒ii⍳i_⍸ee∊e_⍷'+ -'uu∪UU∪nn∩/-⌿\\-⍀,-⍪rr⍴pp⍴O|⌽O-⊖O\\⍉::¨""¨~:⍨~"⍨*:⍣*"⍣oo∘o:⍤o"⍤O:⍥O"⍥[\'⍞\']⍞[]⎕[:⍠:]⍠[=⌸=]⌸[<⌺>]⌺o_⍎oT⍕o-⍕<>⋄^v⋄on⍝->→aa⍺ww⍵VV∇v-∇--¯0~⍬'+ -'AA∆^-∆A_⍙^=⍙[?⍰?]⍰:V⍢∇"⍢||∥ox¤)_⊇_)⊇V~⍫\'\'`' -,lbs=['←←\nASSIGN',' ','++\nconjugate\nplus','--\nnegate\nminus','××\ndirection\ntimes','÷÷\nreciprocal\ndivide','**\nexponential\npower','⍟⍟\nnatural logarithm\nlogarithm', -'⌹⌹\nmatrix inverse\nmatrix divide','○○\npi times\ncircular','!!\nfactorial\nbinomial','??\nroll\ndeal',' ','||\nmagnitude\nresidue', -'⌈⌈\nceiling\nmaximum','⌊⌊\nfloor\nminimum','⊥⊥\ndecode','⊤⊤\nencode','⊣⊣\nsame\nleft','⊢⊢\nsame\nright',' ','==\nequal','≠≠\nunique mask\nnot equal', -'≤≤\nless than or equal to','<<\nless than','>>\ngreater than','≥≥\ngreater than or equal to','≡≡\ndepth\nmatch','≢≢\ntally\nnot match',' ','∨∨\ngreatest common divisor/or', -'∧∧\nlowest common multiple/and','⍲⍲\nnand','⍱⍱\nnor',' ','↑↑\nmix\ntake','↓↓\nsplit\ndrop','⊂⊂\nenclose\npartioned enclose','⊃⊃\nfirst\npick','⊆⊆\nnest\npartition','⌷⌷\nmaterialise\nindex','⍋⍋\ngrade up\ngrades up', -'⍒⍒\ngrade down\ngrades down',' ','⍳⍳\nindices\nindices of','⍸⍸\nwhere\ninterval index','∊∊\nenlist\nmember of','⍷⍷\nfind','∪∪\nunique\nunion','∩∩\nintersection','~~\nnot\nwithout',' ', -'//\nreplicate\nReduce','\\\\\n\expand\nScan','⌿⌿\nreplicate first\nReduce First','⍀⍀\nexpand first\nScan First',' ',',,\nenlist\ncatenate/laminate', -'⍪⍪\ntable\ncatenate first/laminate','⍴⍴\nshape\nreshape','⌽⌽\nreverse\nrotate','⊖⊖\nreverse first\nrotate first', -'⍉⍉\ntranspose\nreorder axes',' ','¨¨\nEach','⍨⍨\nConstant\nSelf\nSwap','⍣⍣\nRepeat\nUntil','..\nOuter Product (∘.)\nInner Product', -'∘∘\nOUTER PRODUCT (∘.)\nBind\nBeside','⍤⍤\nRank\nAtop','⍥⍥\nOver','@@\nAt',' ','⍞⍞\nSTDIN\nSTDERR','⎕⎕\nEVALUATED STDIN\nSTDOUT\nSYSTEM NAME PREFIX','⍠⍠\nVariant', -'⌸⌸\nIndex Key\nKey','⌺⌺\nStencil','⌶⌶\nI-Beam','⍎⍎\nexecute','⍕⍕\nformat',' ','⋄⋄\nSTATEMENT SEPARATOR','⍝⍝\nCOMMENT','→→\nABORT\nBRANCH','⍵⍵\nRIGHT ARGUMENT\nRIGHT OPERAND (⍵⍵)','⍺⍺\nLEFT ARGUMENT\nLEFT OPERAND (⍺⍺)', -'∇∇\nrecursion\nRecursion (∇∇)','&&\nSpawn',' ','¯¯\nNEGATIVE','⍬⍬\nEMPTY NUMERIC VECTOR','∆∆\nIDENTIFIER CHARACTER','⍙⍙\nIDENTIFIER CHARACTER'] -,bqk=' =1234567890-qwertyuiop\\asdfghjk∙l;\'zxcvbnm,./`[]+!@#$%^&*()_QWERTYUIOP|ASDFGHJKL:"ZXCVBNM<>?~{}'.replace(/∙/g,'') -,bqv='`÷¨¯<≤=≥>≠∨∧×?⍵∊⍴~↑↓⍳○*⊢∙⍺⌈⌊_∇∆∘\'⎕⍎⍕∙⊂⊃∩∪⊥⊤|⍝⍀⌿⋄←→⌹⌶⍫⍒⍋⌽⍉⊖⍟⍱⍲!⍰W⍷R⍨YU⍸⍥⍣⊣ASDF⍢H⍤⌸⌷≡≢⊆⊇CVB¤∥⍪⍙⍠⌺⍞⍬'.replace(/∙/g,'') -,tc={},bqc={} //tab completions and ` completions -for(let i=0;i') - for(let j=0;j'+lbs[i][0]+'' -} -let d=document,el=d.createElement('div');el.innerHTML= -`
${lbh}
- +; (_ => { + let hc = { '<': '<', '&': '&', "'": ''', '"': '"' }, he = x => x.replace(/[<&'"]/g, c => hc[c]) //html chars and escape fn + , tcs = '<-←xx×/\\×:-÷*O⍟[-⌹-]⌹OO○77⌈FF⌈ll⌊LL⌊T_⌶II⌶|_⊥TT⊤-|⊣|-⊢=/≠L-≠<=≤<_≤>=≥>_≥==≡=_≡7=≢L=≢vv∨^^∧^~⍲v~⍱^|↑v|↓((⊂cc⊂(_⊆c_⊆))⊃[|⌷|]⌷A|⍋V|⍒ii⍳i_⍸ee∊e_⍷' + + 'uu∪UU∪nn∩/-⌿\\-⍀,-⍪rr⍴pp⍴O|⌽O-⊖O\\⍉::¨""¨~:⍨~"⍨*:⍣*"⍣oo∘o:⍤o"⍤O:⍥O"⍥[\'⍞\']⍞[]⎕[:⍠:]⍠[=⌸=]⌸[<⌺>]⌺o_⍎oT⍕o-⍕<>⋄^v⋄on⍝->→aa⍺ww⍵VV∇v-∇--¯0~⍬' + + 'AA∆^-∆A_⍙^=⍙[?⍰?]⍰:V⍢∇"⍢||∥ox¤)_⊇_)⊇V~⍫\'\'`' + , lbs = ['←←\nASSIGN', ' ', '++\nconjugate\nplus', '--\nnegate\nminus', '××\ndirection\ntimes', '÷÷\nreciprocal\ndivide', '**\nexponential\npower', '⍟⍟\nnatural logarithm\nlogarithm', + '⌹⌹\nmatrix inverse\nmatrix divide', '○○\npi times\ncircular', '!!\nfactorial\nbinomial', '??\nroll\ndeal', ' ', '||\nmagnitude\nresidue', + '⌈⌈\nceiling\nmaximum', '⌊⌊\nfloor\nminimum', '⊥⊥\ndecode', '⊤⊤\nencode', '⊣⊣\nsame\nleft', '⊢⊢\nsame\nright', ' ', '==\nequal', '≠≠\nunique mask\nnot equal', + '≤≤\nless than or equal to', '<<\nless than', '>>\ngreater than', '≥≥\ngreater than or equal to', '≡≡\ndepth\nmatch', '≢≢\ntally\nnot match', ' ', '∨∨\ngreatest common divisor/or', + '∧∧\nlowest common multiple/and', '⍲⍲\nnand', '⍱⍱\nnor', ' ', '↑↑\nmix\ntake', '↓↓\nsplit\ndrop', '⊂⊂\nenclose\npartioned enclose', '⊃⊃\nfirst\npick', '⊆⊆\nnest\npartition', '⌷⌷\nmaterialise\nindex', '⍋⍋\ngrade up\ngrades up', + '⍒⍒\ngrade down\ngrades down', ' ', '⍳⍳\nindices\nindices of', '⍸⍸\nwhere\ninterval index', '∊∊\nenlist\nmember of', '⍷⍷\nfind', '∪∪\nunique\nunion', '∩∩\nintersection', '~~\nnot\nwithout', ' ', + '//\nreplicate\nReduce', '\\\\\n\expand\nScan', '⌿⌿\nreplicate first\nReduce First', '⍀⍀\nexpand first\nScan First', ' ', ',,\nenlist\ncatenate/laminate', + '⍪⍪\ntable\ncatenate first/laminate', '⍴⍴\nshape\nreshape', '⌽⌽\nreverse\nrotate', '⊖⊖\nreverse first\nrotate first', + '⍉⍉\ntranspose\nreorder axes', ' ', '¨¨\nEach', '⍨⍨\nConstant\nSelf\nSwap', '⍣⍣\nRepeat\nUntil', '..\nOuter Product (∘.)\nInner Product', + '∘∘\nOUTER PRODUCT (∘.)\nBind\nBeside', '⍤⍤\nRank\nAtop', '⍥⍥\nOver', '@@\nAt', ' ', '⍞⍞\nSTDIN\nSTDERR', '⎕⎕\nEVALUATED STDIN\nSTDOUT\nSYSTEM NAME PREFIX', '⍠⍠\nVariant', + '⌸⌸\nIndex Key\nKey', '⌺⌺\nStencil', '⌶⌶\nI-Beam', '⍎⍎\nexecute', '⍕⍕\nformat', ' ', '⋄⋄\nSTATEMENT SEPARATOR', '⍝⍝\nCOMMENT', '→→\nABORT\nBRANCH', '⍵⍵\nRIGHT ARGUMENT\nRIGHT OPERAND (⍵⍵)', '⍺⍺\nLEFT ARGUMENT\nLEFT OPERAND (⍺⍺)', + '∇∇\nrecursion\nRecursion (∇∇)', '&&\nSpawn', ' ', '¯¯\nNEGATIVE', '⍬⍬\nEMPTY NUMERIC VECTOR', '∆∆\nIDENTIFIER CHARACTER', '⍙⍙\nIDENTIFIER CHARACTER'] + , bqk = ' =1234567890-qwertyuiop\\asdfghjk∙l;\'zxcvbnm,./`[]+!@#$%^&*()_QWERTYUIOP|ASDFGHJKL:"ZXCVBNM<>?~{}'.replace(/∙/g, '') + , bqv = '`÷¨¯<≤=≥>≠∨∧×?⍵∊⍴~↑↓⍳○*⊢∙⍺⌈⌊_∇∆∘\'⎕⍎⍕∙⊂⊃∩∪⊥⊤|⍝⍀⌿⋄←→⌹⌶⍫⍒⍋⌽⍉⊖⍟⍱⍲!⍰W⍷R⍨YU⍸⍥⍣⊣ASDF⍢H⍤⌸⌷≡≢⊆⊇CVB¤∥⍪⍙⍠⌺⍞⍬'.replace(/∙/g, '') + , tc = {}, bqc = {} //tab completions and ` completions + for (let i = 0; i < bqk.length; i++)bqc[bqk[i]] = bqv[i] + for (let i = 0; i < tcs.length; i += 3)tc[tcs[i] + tcs[i + 1]] = tcs[i + 2] + for (let i = 0; i < tcs.length; i += 3) { let k = tcs[i + 1] + tcs[i]; tc[k] = tc[k] || tcs[i + 2] } + let lbh = ''; for (let i = 0; i < lbs.length; i++) { + let ks = [] + for (let j = 0; j < tcs.length; j += 3)if (lbs[i][0] === tcs[j + 2]) ks.push('\n' + tcs[j] + ' ' + tcs[j + 1] + ' ') + for (let j = 0; j < bqk.length; j++)if (lbs[i][0] === bqv[j]) ks.push('\n` ' + bqk[j]) + lbh += '' + lbs[i][0] + '' + } + let d = document, el = d.createElement('div'); el.innerHTML = + `
${lbh}
+ ` -d.body.appendChild(el) -let t,ts=[],lb=el.firstChild,bqm=0 //t:textarea or input, lb:language bar, bqm:backquote mode -let pd=x=>x.preventDefault() -let ev=(x,t,f,c)=>x.addEventListener(t,f,c) -ev(lb,'mousedown',x=>{ - if(x.target.classList.contains('ngn_x')){lb.hidden=1;upd();pd(x);return} - if(x.target.nodeName==='B'&&t){ - let i=t.selectionStart,j=t.selectionEnd,v=t.value,s=x.target.textContent - if(i!=null&&j!=null){t.value=v.slice(0,i)+s+v.slice(j);t.selectionStart=t.selectionEnd=i+s.length} - pd(x);return - } -}) -let fk=x=>{ - let t=x.target - if(bqm){let i=t.selectionStart,v=t.value,c=bqc[x.key];if(x.which>31){bqm=0;d.body.classList.remove('ngn_bq')} - if(c){t.value=v.slice(0,i)+c+v.slice(i);t.selectionStart=t.selectionEnd=i+1;pd(x);return!1}} - if (!x.ctrlKey && !x.shiftKey && !x.altKey && !x.metaKey) { - if ("`½²^º§ùµ°".indexOf(x.key) > -1) { - bqm=1;d.body.classList.add('ngn_bq');pd(x); // ` or other trigger symbol pressed, wait for next key - } else if (x.key == "Tab") { - let i=t.selectionStart,v=t.value,c=tc[v.slice(i-2,i)] - if(c){t.value=v.slice(0,i-2)+c+v.slice(i);t.selectionStart=t.selectionEnd=i-1;pd(x)} - } - } -} -let ff=x=>{ - let t0=x.target,nn=t0.nodeName.toLowerCase() - if(nn!=='textarea'&&(nn!=='input'||t0.type!=='text'&&t0.type!=='search'))return - t=t0;if(!t.ngn){t.ngn=1;ts.push(t);ev(t,'keydown',fk)} -} -let upd=_=>{d.body.style.marginTop=lb.clientHeight+'px'} -upd();ev(window,'resize',upd) -ev(d,'focus',ff,!0);let ae=d.activeElement;ae&&ff({type:'focus',target:ae}) + d.body.appendChild(el) + let t, ts = [], lb = el.firstChild, bqm = 0 //t:textarea or input, lb:language bar, bqm:backquote mode + let pd = x => x.preventDefault() + let ev = (x, t, f, c) => x.addEventListener(t, f, c) + ev(lb, 'mousedown', x => { + if (x.target.classList.contains('ngn_x')) { lb.hidden = 1; upd(); pd(x); return } + if (x.target.nodeName === 'B' && t) { + let i = t.selectionStart, j = t.selectionEnd, v = t.value, s = x.target.textContent + if (i != null && j != null) { t.value = v.slice(0, i) + s + v.slice(j); t.selectionStart = t.selectionEnd = i + 1 } + pd(x); return + } + }) + let fk = x => { + let t = x.target + if (bqm) { + let i = t.selectionStart, v = t.value, c = bqc[x.key]; if (x.which > 31) { bqm = 0; d.body.classList.remove('ngn_bq') } + if (c) { t.value = v.slice(0, i) + c + v.slice(i); t.selectionStart = t.selectionEnd = i + 1; pd(x); return !1 } + } + if (!x.ctrlKey && !x.shiftKey && !x.altKey && !x.metaKey) { + if ("`½²^º§ùµ°".indexOf(x.key) > -1) { + bqm = 1; d.body.classList.add('ngn_bq'); pd(x); // ` or other trigger symbol pressed, wait for next key + } else if (x.key == "Tab") { + let i = t.selectionStart, v = t.value, c = tc[v.slice(i - 2, i)] + if (c) { t.value = v.slice(0, i - 2) + c + v.slice(i); t.selectionStart = t.selectionEnd = i - 1; pd(x) } + } + } + } + let ff = x => { + let t0 = x.target, nn = t0.nodeName.toLowerCase() + if (nn !== 'textarea' && (nn !== 'input' || t0.type !== 'text' && t0.type !== 'search')) return + t = t0; if (!t.ngn) { t.ngn = 1; ts.push(t); ev(t, 'keydown', fk) } + } + let upd = _ => { d.body.style.marginTop = lb.clientHeight + 'px' } + upd(); ev(window, 'resize', upd) + ev(d, 'focus', ff, !0); let ae = d.activeElement; ae && ff({ type: 'focus', target: ae }) })();