-
-
Notifications
You must be signed in to change notification settings - Fork 8
/
Copy pathjelly.js
62 lines (62 loc) · 24.3 KB
/
jelly.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
; (_ => {
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<link>ÐL", "MM\nmonad\nReturn all indices of z that correspond to maximal elements.", "NN\nmonad\nNegative; compute −z.\n\nÆN\nmonad\nGenerate the z<sup>th</sup> 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<link>ÐṂ", "ṆṆ\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(zz<sup>T</sup>)<sup>½</sup>; 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<link>ÐṀ", "ṄṄ\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<condition>Ð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<sup>−y</sup>.\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<condition>Ðḟ", "ḣḣ\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 × 2<sup>y</sup>.", "»»\ndyad\nMaximum of x and y.\n\næ»\ndyad\nBit shift; compute x × 2<sup>−y</sup>. Returns an integer.", " \nSYNTAX\nToken separator.", "©©\nQuick\nCopy link result to register (® atom to retrieve).\n<link>©", "ßß\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<index>£", "ĿĿ\nQuick\nLink at index n as a monad.\n<index>Ŀ\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<index>ŀ", "¦¦\nQuick\nApply link to items at specific indices.\n<link><indices>¦", "¡¡\nQuick\nRepeat n times.\n<link><repetitions>¡\n\nÆ¡\nmonad\nConvert from factorial base to integer.\n\nС\nQuick\nLike ¡. Collects all intermediate results.", "¿¿\nQuick\nWhile loop.\n<body><condition>¿\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<dyad>/ or <dyad><nilad>/", "\\\\\nQuick\nCumulative reduce or n-wise overlapping reduce.\n<dyad>\\ or <dyad><nilad>\\", "¤¤\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<condition><amount>#", "??\nQuick\nTernary if.\n<if-clause><else-clause><condition>?\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<dyad>@", "``\nQuick\nMake a monad from a dyad by repeating the argument.\n<dyad>`", "\"\"\nQuick\nVectorize/zipwith.\n<dyad>\"", "''\nQuick\nFor monads, flat. For dyad, spawn.\n<monad/dyad>'", "þþ\nQuick\nOuter product/table.\n<dyad>þ", "{{\nQuick\nTurn a monad into a dyad. Uses the left argument.\n<monad>{", "}}\nQuick\nTurn a monad into a dyad. Uses the right argument.\n<monad>}", "€€\nQuick\nEach. Map a link over its left argument.\n<monad/dyad>€\n\nЀ\nQuick\nEach. Map a link over its right argument.\n<dyad>Ѐ", "ÞÞ\nQuick\nSort by some key function.\n<monad>Þ", "ƝƝ\nQuick\nApply a dyadic link or a monadic chain for all pairs of neighboring elements.\n<any>Ɲ", "ƤƤ\nQuick\nMap a link over prefixes, and if given a <nilad>, overlapping infixes if positive, or the overlapping outfixes of abs(<nilad>) if negative.\n<monad>Ƥ or <monad><nilad>Ƥ\n\nÐƤ\nQuick\nMap a link over suffixes, and if given a <nilad>, non-overlapping infixes if positive, or the non-overlapping outfixes of abs(<nilad>) if negative.\n<monad>ÐƤ or <monad><nilad>ÐƤ", "ƙƙ\nQuick\nKey. Map a link over the groups formed by identical items.\n<monad>ƙ", "ƭƭ\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 <link><newline><line>", "øø\nSYNTAX\nStarts a separate niladic chain. ø<link>", "µµ\nSYNTAX\nStarts a separate monadic chain. µ<link>", "ðð\nSYNTAX\nStarts a separate dyadic chain. ð<link>", "ɓɓ\nSYNTAX\nStarts a separate dyadic chain with reversed arguments. ɓ<link>", "ıı\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] + ' <tab>')
for (let j = 0; j < bqk.length; j++)if (lbs[i][0] === bqv[j]) ks.push('\n` ' + bqk[j])
lbh += '<b title="' + he(lbs[i].slice(1) + (ks.length ? '\n' + ks.join('') : '')) + '">' + lbs[i][0] + '</b>'
}
let d = document, el = d.createElement('div'); el.innerHTML =
`<div class=ngn_lb><span class=ngn_x title=Close>❎</span>${lbh}</div>
<style>@font-face{font-family:"DVSM";src:local("DejaVu Sans Mono"),url(//abrudz.github.io/lb/DejaVuBQNSansMono.ttf)format('truetype');}</style>
<style>
.ngn_lb{position:fixed;top:0;left:0;right:0;background-color:#eee;color:#000;cursor:default;z-index:2147483647;
font-family:"DVSM",monospace;border-bottom:solid #999 1px;padding:2px 2px 0 2px;word-wrap:break-word;}
.ngn_lb b{cursor:pointer;padding:0 1px;font-weight:normal}
.ngn_lb b:hover,.ngn_bq .ngn_lb{background-color:#777;color:#fff}
.ngn_x{float:right;color:#999;cursor:pointer;margin-top:-3px}
.ngn_x:hover{color:#f00}
</style>`
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 })
})();