Japt

  1. v1.4.5
  2. v1.4.6
  3. v2.0a0

Flags

Code

1 byte (ISO-8859-1)

Transpiled JS

U.u()
הההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההה
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

Input

Output

0.000 seconds

  1. Introduction
  2. Interpreter
  3. Japt Basics
  4. Variables
  5. Shortcuts
  6. Compression
  7. Regular Expressions
  8. String Methods
  9. Array Methods
  10. Number Methods
  11. Function Methods
  12. Date Methods
  13. Math Methods
  14. Other Methods
  15. Flags
  16. Examples
  17. Settings

Documentation

Introduction

This documentation provides an overview of the features, functions & methods of Japt. For more in-depth tutorials, see the tips for golfing in Japt on PPCG, join the Japt chatroom or have a look through some recent solutions.

The documentation's sections can be navigated via the icon in the top-right corner and the various methods can be searched by clicking on the icon.

You can change the order of the sections in this documentation to move the ones you use the most to the top of the menu. The new order will also be used when searching methods.

Version labels such as v1.4.6 are used to indicate which version of Japt a feature or method was added in.

Shortcuts and method names can be inserted into the code by clicking on them.

The following abbreviations are used throughout the documentation, uppercase for objects and lowercase for method arguments:

  1. A: Array
  2. B: Boolean
  3. D: Date
  4. F: Function/Method
  5. N: Number
  6. R: RegExp
  7. S: String
  8. X: Any type

Interpreter

The following is an overview of the differences between this interpreter & the official one and some of the additional features available.

Versions

This interpreter includes support for Japt v1.4.5 and above only, with the current being v1.4.6. Click the version number in the header to switch to a different one. Doing so will retain the values enter in the flags, code & input fields, but not the explanation or compressor fields.

Copying

You can copy your programme as a link, which includes the flags, code & input, by clicking the icon in the header or as markdown, ready to post to PPCG using the icon. Markdown includes a header containing the language name, linked to the GitHub repo; the version used, if different to the current version; the flag(s) used, if any, linked to the relevant meta post on flag usage & the byte count as well as your code, formatted as a code block; the link described above and, if provided the contents of the explanation field, formatted as a code block. Clicking one of the icons will copy the contents of the field below it.

Flags

A dedicated field is provided for flags, but as with the official interpreter, they can be entered directly into the input field instead, if you prefer.

Auto-Golf

Click the icon above the code field to have the interpreter walk through your code, replacing any matches it finds for substrings that have shortcuts with those shortcuts. This may take a moment for longer programmes and/or programmes where multiple replacements can be made.

Keyboard

As Japt makes use of the full range of printables in ISO-8859-1 a character map is provided to allow you to enter characters not commonly found on all keyboards. Click the tab at the bottom of the page and then click on a character to insert it into your could at the current location of the caret.

Output Caching

Output caching can be enabled by checking the box above the output field. While enabled, any programmes taking longer than 100ms will be written to a local cache and running the same programme (where flags, code & input are identical) again will return the cached output value. The cache's size is limited to 50 programmes and it persists across sessions in the same browser. You can clear the cache by clicking the icon while it is enabled.

Compressor

A built-in tool, based on this tip, is included for compressing strings and arrays. See the compression section for more information on Japt's compression and details on how to use the compressor.

Projects

Accessible via the tab on the left of the page, projects allow you to locally save work-in-progress programmes, favourite solutions, custom tools, etc. for future reference. Enter some code, at least, provide a name & optional challenge URL for your project and click the icon to add it to your list. Each project stores the contents of all editable fields on the page as well as the current status of output caching and the compressor's permutations. Click the icon next to a project in your list to load and run the project, the icon to open the project's challenge URL or the icon to delete the project from your list.

Credits

Japt Basics

Japt is JavaScript

As Japt is based on JavaScript, anything that holds true in JS also holds true in Japt. This includes things like 0-based indexing and which values are considered truthy or falsey. Unlike JS, though, Japt supports index wrapping.

Variables, Methods & Functions

The uppercase letters A-Z are pre-defined variables with U-Z being reserved for the first 6 inputs, each defaulting to 0. See the "Variables" section for more information.

The lowercase letters a-z and accented lowercase letters are various methods, which transpile to .a(, etc. See the individual "Methods" sections for more information.

Anonymous functions take the form XYZ{, which transpiles to function(X,Y,Z){ with X, Y & Z being the parameters.

@ is equivalent to XYZ{ and _ is equivalent to Z{Z.

If a lowercase letter or infix operator is passed as the first argument of a method expecting a function as an argument then it is treated as a method itself. If it is preceded by a ! then its arguments are reversed. See this tip for a more in-depth explanation of these "auto-methods".

Parentheses

Use to insert ) and close a single method.

Use ) to insert )) and close two methods.

Use ¹ to insert ))) and close three methods.

Shortcuts

Various characters between ¡ and × transpile to sequences of 2 or more characters. See the Shortcuts section for the complete list.

Outside of string literals, any character preceded by a ' is treated as a single character string. For example 'a transpiles to "a".

Any character preceded by a # is converted to the number corresponding to that character's codepoint. For example #z transpiles to 122.

Multiple codepoints can be chained together to create larger numbers. For example #x#y#z transpiles to 120121122.

Auto-Insertion

If a function or a line of a programme begins with a method name, mathematical operator, comparative operator, && or || then the first input variable U is automatically inserted before it.

Similarly, if a variable name immediately precedes a mathematical operator, comparative operator, && or || followed by a method call on the same variable then the variable name after the operator may be omitted (e.g., U*x is the same as U*Ux).

Any parentheses omitted before }, ], ;, : or the end of a programme will be inserted automatically.

Any of , }, ", `, $ & / may be omitted at the end of a programme and will be inserted automatically.

String Interpolation

String interpolation is achieved similarly to JavaScript's template literals. For example "abc{X}xyz" transpiles to "abc"+(X)+"xyz".

String interpolation may also be nested, with no limit to the number of levels. For example "abc{"123{X}456"}xyz" transpiles to "abc"+("123"+(X)+"456")+"xyz".

String Compression

Japt uses the shoco library to compress runs of lowercase letters in strings. See the "Compression" section for more information and details on how to use the interpreter's built-in compressor.

Miscellaneous

Whenever you start a new line in programme the result of the previous line is automatically assigned to one of the input variables U-Z in order before wrapping back around to A.

Anything wrapped in $s is evaluated as pure JavaScript.

Use ß to re-run a programme. Arguments passed to it will be used as the input variables. If any arguments are ommitted the the current value of those input variables will be passed instead.

In v2.0a0 and above / is used to enclose Regular Expressions so ÷ is used for division instead.

Variables

Alternative variables are available, in v1.4.x only, by inserting a ; at the beginning of the programme.

VariableValueAlternative
A10[]
B11Alphabet
C12Alphabet
D13QWERTY
E14ASCII
F15"[A-Za-z]"
G1636
H3265
I6491
J-1","
Knew Date()
L100"."
MMath
NInput
OOther
P""
Q"\""
R"\n"
S" "
T0
U1st Input
V2nd Input
W3rd Input
X4th Input
Y5th Input
Z6th Input

Additionally, the following constants are available as part of the Math object

VariableValue
MEEuler's Constant
MPPi
MQGolden Ratio
MRsqrt(0.5) ( = ½¬)
MSsqrt(2) ( = )
MTTau ( = Pi*2)

Shortcuts

CharacterCodeVersion
ÈXYZ{Xv1.4.5
ÏXYZ{Yv1.4.5
Îg v1.4.5
ÌgJ v1.4.5
Êl v1.4.5
¡Um@v1.4.5
£m@v1.4.5
®m_v1.4.5
ËmDEF{Dv1.4.5
Ín2 v1.4.5
Æo@v1.4.5
Ço_v1.4.5
²p2 v1.4.5
³p3 v1.4.5
¬q v1.4.5
·qR v1.4.5
¸qS v1.4.5
×r*1 v1.4.5
¯s0,v1.4.5
Ås1 v1.4.5
¢Us2 v1.4.5
¤s2 v1.4.5
Ôw v1.4.6
Õy v1.4.6
Ã} v1.4.5
¹) v1.4.5
Ä+1v1.4.5
°++v1.4.5
±+=v1.4.5
É-1v1.4.5
´--v1.4.5
µ-=v1.4.5
Ñ*2v1.4.5
À!==v1.4.5
¦!=v1.4.5
===v1.4.5
¥==v1.4.5
§<=v1.4.5
¨>=v1.4.5
«&&!v1.4.5
©&&v1.4.5
ª||v1.4.5
Ò-~v1.4.6
Ó~-v1.4.6
Â~~v1.4.5
Á>>>v1.4.5
¼.25v1.4.5
½.5v1.4.5
¾.75v1.4.5
»(((v1.4.5
º((v1.4.5

Compression

Japt uses the shoco library to compress runs of lowercase letters in strings.

The interpreter also includes a built-in tool for compressing strings & arrays.

If the order of elements in an array is irrelevant then you can have the compressor try different permutations and delimiters by clicking the icon before running it. The permutation used will be returned in the results along with the original array.

After running the compressor, clicking the icon will insert the compressed string into your code and clicking the icon will copy it to your clipboard.

Compressing Strings

Enter a string enclosed in "s, click the icon and the compressor will return the original string & its size, including enclosing quotation marks, and the compressed string & its size, including enclosing backticks.

Compressing String Arrays

Joining an array of strings to a single string with a space, newline or lowercase letter not contained in any of the strings, which can then be split back to an array on the character used, usually works out a lot shorter than compressing each string in the array individually. The compressor takes the effort out of testing each possible delimiter individually to see which gives the best results, especially when trying to factor in the shortcuts available in Japt that might save another byte or 2.

Enter an array enclosed in [] and with each string enclosed in "s (delimiting ,s are optional), click the icon and the compressor will return the original array without delimiting commas, the permutation used, its size, including square brackets & quotation marks, the compressed string, the delimiter used and the size of the compressed string, including backticks, the split method and, where applicable, a trailing space to close the split method.

Compressing Integer Arrays

Arrays of large integers can be compressed in a similar way to string arrays with the compressor first converting each integer to a string in all bases between 11 & 36.

Enter an array of integers enclosed in [], click the icon and the compressor will return the original array, the permutation used, its size, including square brackets, the compressed string, the base & delimiter used and the size of the compressed string, including backticks, the split method, the map method (to convert each string back to an integer) and a trailing space to close the map method.

Note that, if you are mapping over the array in your code anyway, you will probably save a few more bytes by moving the base conversion method into that map.

Limitations

There is a limit to the number of strings shoco can compress at the same time so be aware that, when compressing an array with permutations enabled, it will throw an error when the number of elements in the original array reaches 7 or 8 and then stop working altogether until the page is reloaded.

Regular Expressions

Before v2.0a0

Regular Expressions are strings, with % used instead of \ for character classes and as the escape character.

Flags must be passed as a separate string argument to methods that support them.

The global flag is enabled by default.

From v2.0a0 On

Regular Expressions use the more familiar /<exp>/<flags> syntax, with \ used for character classes and as the escape character.

The global flag is enabled by default.

Missing parentheses or square brackets at the beginning or end of an expression are inserted automatically.

. is automatically inserted before any of +, *, or ? that would otherwise cause a syntax error.

The enclosing /s can be omitted from an expression containing only a single character class. For example \w transpiles to /\w/g.

The s (dotAll) flag has been implemented for browsers that don't yet support it, which forces . to include newlines in matches.

The R.t(s) method is available for testing if s contains any matches for R, returning true if it does, or false if not.

Character Classes

ClassMatchesVersion
%wA-Z, a-z & 0-9v1.4.5
%WEverything elsev1.4.5
%d0-9v1.4.5
%DEverything elsev1.4.5
%sWhitespacev1.4.5
%SEverything elsev1.4.5
%nNewlinev1.4.5
%tTabv1.4.5
%bWord boundaryv1.4.5
%BEverything elsev1.4.5
%aa-zv1.4.5
%AA-Zv1.4.5
%lA-Z & a-zv1.4.5
%LEverything elsev1.4.5
%pASCIIv1.4.5
%PEverything elsev1.4.5
%qASCII & newlinev1.4.5
%QEverything elsev1.4.5
%vVowelsv1.4.5
%VEverything elsev1.4.5
%yVowels & Yyv1.4.5
%YEverything elsev1.4.5
%cConsonantsv1.4.5
%CEverything elsev1.4.5

The following shortcut classes are also available in v2.0a0 and above.

ClassTranspiled
\././g
\*/.*/g
\+/.+/g
\?/.?/g
\^/[^]/g

String Methods

a(s/n)N

Returns the last index of s/n in S, or -1 if not found.

a(r)N

Returns the index of the last character in S that matches r, or -1 if none do.

a(f)N

Returns the index of the last character in S to return a truthy value when passed through f, or -1 if none do.

b(s/n)N

Returns the first index of s/n in S, or -1 if not found.

b(r)N

Returns the index of the first character in S that matches r, or -1 if none do.

b(f)N

Returns the index of the first character in S to return a truthy value when passed through f, or -1 if none do.

c(n=0)N

Returns the codepoint of the character in S at index n.

c(f)S

Returns the result of passing the codepoints of each character in S through f.

d(s)S

Returns the result of replacing x with y in S for each pair of characters xy in s.

d(s/n,...,s/n)S

Returns the result of replacing x with y in S for each pair of arguments x,y.

e(r/s/n,s/n/a="")S

Returns the result of recursively replacing occurrences of r/s/n in S with s/n/a.

f(r/s/n)A

Returns all occurrences of r/s/n in S.

g(n=0)S

Returns the character in S at index n.

g(f)S

Returns the result of running S through f.

h(s,n=0)S

Returns the result of replacing the characters starting at index n in S with s. Arguments may be passed in any order.

i(s,n=0)S

Returns the result of inserting s in S at index n. Arguments may be passed in any order.

j(n1,n2=1)S

Returns the result of removing n2 characters from S starting from index n1.

k(s/n/a,x?)S

Returns the result of removing all characters in s/n/a from S. Case-insensitive unless x is truthy.

k(f)S

Returns the result of removing all characters from S that return a truthy value when passed through f.

l()N

Returns the length of S.

m(f,s="")S

Returns the result of splitting S on s, passing each item through f and then rejoining with s.

n(n=10)N

Returns S converted from a base-n string to a base-10 integer. n is limited to 2-36, inclusive.

n(s/a)N

Returns the result of converting S from a base-s/a string to a base-10 integer. (e.g., "baab".n("ab") = "1001".n(2) = 9)

n(x,x)S

Returns the result of converting S from a base-x1 to a base-x2 string.

n(x=10,x?,f)S

Returns the result of converting S from a base-x1 string to a base-10 integer, passing it through f and then converting it to a base-x2 string. If x2 is not passed then the result will be converted back to the original base.

o(s/n/a,x?)S

Returns the result of removing all characters not in s/n/a from S. Case-insensitive unless x is truthy.

o(f)S

Returns the result of removing all characters from S that return a falsey value when passed through f.

p(n=2)S

Returns S repeated n times.

p(f)S

Returns the result of passing S through f and appending it to the original S.

q(s="")A

Returns S split on s.

r(s1,s2/n="",s3="g")S

Returns the result of replacing s1 with s2/n in S. Regular Expression flags can be passed via parameter s3.

r(r,s/n="")S

Returns the result of replacing r with s/n in S.

s(n1=0,n2=S.length)S

Returns the result of slicing S from index n1 to n2.

t(n1=0,n2=S.length)S

Returns a length n2 substring of S starting from index n1.

u()S

Returns S converted to uppercase.

v()S

Returns S converted to lowercase.

w()S

Returns S reversed.

x(n?)S

Returns S with whitespace trimmed. Only trims from the right if n=1, or the left if n=2.

y()S

Returns the result of splitting S on newlines, transposing rows with columns and then rejoining with newlines.

y(f)S

Returns the result of passing each column in S through f.

z(n=1)S

Returns the result of splitting S on newlines, rotating clockwise by n*90 degrees and then rejoining with newlines.

à(n?)A

Returns all combinations of S. If n is passed, returns all combinations of length n.

á(n?)A

Returns all unique permutations of S. If n is passed, returns all permutations of length n.

â(r/s/n)N

Returns the first index of r/s/n in S, or -1 if not found. Moved to S.b(r) in v2.0a0 (See below)

â()S

Returns the unique characters in S in the order they first appear.

ã(n?,s/a?)A

Returns all substrings of S. If n is passed, returns all substrings of length n. Prior to v1.4.6 n defaults to 2. If s/a is also passed then it is first prepended to the array.

ã(f)A

Returns all substrings of S after passing each through f.

ä(f,s/a?)A

Returns the result of passing each consecutive pair of characters x,y in S through f with arguments (x,y,x+y). If s/a is passed then it is first prepended to the array.

å(f,x=S[0])A

Returns the result of splitting S and cumulatively reducing it by f with an initial value of x.

ç(s)S

Returns S with each character replaced with s.

è(r/s/n)N

Returns the number of occurrences of r/s/n in S.

é(n=1)S

Returns the result of rotating S right by n characters.

ê(n=0)S

Returns S palindromised if n%2=0, or the reverse of S appended to S.

ê(s)B

Returns true if S is a palindrome, or false if it isn't

ë(n1=2,n2=0)S

Returns every n1th character of S starting from index n2.

í(s/a?,f=+)S

Returns the result of pairing each character in S with the corresponding character in s, or element in a, and reducing each pair by f. If s/a is not passed then indices of the characters in S are used instead.

î(s=" ")S

Returns s repeated and sliced to the length of S.

ï(s/a=S,f=+)A

Returns the result of pairing each character in S with each character in s, or element in a, and reducing each pair by f.

ð(r/s/n,x?)A

Returns the indices of S where a match for r/s/n begins. Case-sensitive unless x is truthy.

ñ(f?)S

Returns the characters of S sorted as though they had been passed through f.

ò(n=2)A

Returns S partitioned into strings of length n. If n is negative then partitions from the end of S

ò(f)A

Returns S partitioned between each pair of characters that return a truthy value when passed through f.

ó(n=2)A

Returns S split into n strings each containing every nth character of S.

ó(f)A

Returns S partitioned between each pair of characters that return a falsey value when passed through f.

ô(f)A

Returns S partitioned at each character that returns a truthy value when passed through f.

ö(n=1)S

Returns n random characters from S with n rounded up to the nearest whole number, if necessary.

ö(x)S

Returns a random permutation of S.

ø(s/n)B

Returns true if S contains s/n, or false if it doesn't.

ø(a)B

Returns true if S contains any element of a, or false if it doesn't.

ù(s=" ",n?)S

Returns the result of left-padding each line in S with s to length n. If n is not passed then the length of the longest line is used.

ú(s=" ",n?)S

Returns the result of right-padding each line in S with s to length n. If n is not passed then the length of the longest line is used.

û(s=" ",n?)S

Returns the result of centre-padding each line in S with s to length n. If n is not passed then the length of the longest line is used.

Array Methods

a(s/n)N

Returns the last index of s/n in A, or -1 if not found.

a(f)N

Returns the index of the last element in A to return a truthy value when passed through f, or -1 if none do.

b(s/n)N

Returns the first index of s/n in A, or -1 if not found.

b(f)N

Returns the index of the first element in A to return a truthy value when passed through f, or -1 if none do.

c()A

Returns A flattened.

c(n)A

Returns A flattened by n levels.

c(f)A

Returns the result of passing each element in A through f and then flattening by 1 level.

c(a)A

Returns the result of concatenating a to A.

d(f?)B

Returns true if any element of A returns a truthy value when passed through f, or false if none do.

e(f?)B

Returns true if every element of A returns a truthy value when passed through f, or false if any doesn't.

e(a)B

Returns true if every element of A is exactly equal to the corresponding element of a, or false if any isn't. Supports multi-dimensional arrays as of v1.4.6.

f(f?)A

Returns the elements of A that return a truthy value when passed through f.

f(a,n=0)A

Returns the elements of A that are also contained in a if n%3=0; the unique elements that appear in both A and a if n%3=1; or the elements that appear in both A and a if n%3=2.

g(n=0)X

Returns the element in A at index n.

g(n,...,n)X

Returns the element in multi-dimensional A at index n,...,n.

g(n,...,n?,f)A

Returns A after first passing the element at index n,...,n through f. Modifies the original A.

g(a)A

Returns the elements in A at the indices in a.

g(a,f)A

Returns A after first passing the elements at the indices in a through f. Modifies the original A.

g(f)A

Returns the result of passing A through f.

h(n=0,x)A

Returns A with the element at index n replaced with x. Modifies the original A. Arguments may be passed in any order unless x is an integer.

i(n=0,x)A

Returns A with x inserted at index n. Modifies the original A. Arguments may be passed in any order unless x is an integer.

j(n1=0,n2=1)A

Returns n2 elements from A starting at index n1. Modifies the original A by removing those elements.

k(f?)A

Returns the elements of A that return a falsey value when passed through f.

k(a)A

Returns A with the elements in a removed.

k(x)A

Returns A with x removed.

l()N

Returns the length of A.

l(f)A

Returns elements of A whose lengths return a truthy value when passed through f.

l(n)A

Returns elements of A of length n.

m(f)A

Returns the result of passing each element in A through f.

n(f?)A

Returns A sorted by passing each pair of elements x,y through f. Sorts x to the left if f returns a value <0 or y to the left if >0. Modifies the original A.

n(a)A

Returns A sorted by the index of each element in a.

n(s)A

Returns A sorted lexicographically using the alphabet s.

o(n=1)A/X

Returns the last n elements of A. If n=1 then the element itself is returned. Modifies the original A by removing those elements.

o(f)A

Returns the result of passing the last element in A through f. Modifies the original A.

p(x,...,x)A

Returns the result of appending each x to A. Modifies the original A.

q(x="")S

Returns A joined with x.

r(f,x=A[0])X

Returns the result of reducing A by f with an initial value of x.

s(n1=0,n2=A.length)A

Returns the result of slicing A from index n1 to n2.

t(n1=0,n2=A.length)A

Returns n2 elements from A starting at index n1.

u(x,...,x)A

Returns the result of prepending each x to A. Modifies the original A.

v()X

Returns the first element of A. Modifies the original A by removing that element.

v(n=1)A

Returns the first n elements of A. Modifies the original A by removing those elements.

v(f)A

Returns the result of passing the first element in A through f. Modifies the original A.

w()A

Returns A reversed. Modifies the original A.

x(f?)N

Returns the result of reducing A by addition after first passing each element through f.

y()A

Returns the transposing rows and columns of each element.

y(f)A

Returns the result of passing each column in A through f.

z(n=1)A

Returns the result of rotating A clockwise by n*90 degrees.

à(n?)A

Returns all combinations of A. If n is passed, returns all combinations of length n.

á(n?)A

Returns all unique permutations of A. If n is passed, returns all permutations of length n.

â(x?)A

Returns the unique elements of A in the order they first appear. If x is passed then it is concatenated to A first.

ã(n?,s/a?)A

Returns all subsections of A. If n is passed, returns all subsections of length n. Prior to v1.4.6 n defaults to 2. If s/a is also passed then it is first prepended to the array.

ã(f)A

Returns all subssections of A after passing each through f.

ä(f,s/a?)A

Returns the result of passing each consecutive pair of elements x,y in A through f with arguments (x,y,x+y). If s/a is passed then it is first prepended to the array.

å(f,x=A[0])A

Returns the result of cumulatively reducing A by f with an initial value of x.

æ(f?)X

Returns the first element of A to return a truthy value when passed through f.

ç(x)A

Returns A with each element replaced with x.

è(f)N

Returns the number of elements in A that return a truthy value when passed through f.

é(n=1)A

Returns the result of rotating A right by n elements.

ê(n=0)A

Returns A palindromised if n%2=0, or the reverse of A concatenated to A.

ê(s)B

Returns true if A is a palindrome, or false if it isn't

ë(n1=2,n2=0)A

Returns every n1th element of A starting from index n2.

ì(n/s/a)N

Returns the result of converting A from an array of base-n/s/a digits to a base-10 integer. (e.g., ["b","a","a","b"].n("ab") = [1,0,0,1].ì(2) = 9)

ì(x,x)A

Returns the result of converting A from an array of base-x1 digits to an array of base-x2 digits.

ì(x=10,x?,f)A

Returns the result of converting S from an array of base-x1 digits to a base-10 integer, passing it through f and then converting it to an array of base-x2 digits. If x2 is not passed then the result will be converted back to the original base.

í(a?,f?)A

Returns the result of pairing each element in A with the corresponding element in a. If a is not passed then the indices of the elements in A are used instead. If f is passed then each pair of elements is reduced by passing it through f.

î(a/s=[0])A

Returns a/s repeated and sliced to the length of A.

ï(a=A,f?)A

Returns the result of pairing each element in A with each element in a and reducing each pair by f. If f is passed then each pair of elements is reduced by passing it through f.

ð(f?)A

Returns the indices of the elements in A that return a truthy value when passed through f.

ð(n)A

Returns the indices of the elements in A.

ñ(f?)A

Returns the elements of A sorted as though they had been passed through f.

ò(n=2)A

Returns A partitioned into arrays of length n. If n is negative then partitions from the end of A

ò(f)A

Returns A partitioned between each pair of elements that return a truthy value when passed through f.

ó(n=2)A

Returns A partitioned into n arrays each containing every nth element of A.

ó(f)A

Returns A partitioned between each pair of elements that return a falsey value when passed through f.

ô()A

Returns A partitioned at each falsey element.

ô(f)A

Returns A partitioned at each element that returns a truthy value when passed through f.

ö(n=1)A/X

Returns n random elements from A with n rounded up to the nearest whole number, if necessary. If n=1 then the element itself is returned.

ö(s)A

Returns a random permutation of A.

ö(f)X

Returns a random element of A that returns a truthy value when passed through f.

ø(a)B

Returns true if A contains any element of a, or false if it doesn't.

ø(x)B

Returns true if A contains x, or false if it doesn't.

ù(s=" ",n?)A

Returns the result of left-padding each element in A with s to length n. If n is not passed then the length of the longest element is used.

ú(s=" ",n?)A

Returns the result of right-padding each element in A with s to length n. If n is not passed then the length of the longest element is used.

û(s=" ",n?)A

Returns the result of centre-padding each element in A with s to length n. If n is not passed then the length of the longest element is used.

ü(f?)A

Returns the elements of A sorted and grouped by the values returned by passing each through f.

Number Methods

a(n=0)N

Returns the absolute difference of N and n.

b(n1,n2=N)N

Returns n1 if N, n2 if N>n2, or N otherwise.

c(n=1)N

Returns N rounded up to the nearest multiple of n.

d(n=0)S

Returns the character at codepoint N+n.

e(n)S

Returns N*(10**n) (N multiplied by 10 raised to the power of n).

f(n=1)N

Returns N rounded down to the nearest multiple of n.

g()N

Returns the sign of N; -1 if negative, 1 if positive, 0 if N=0, or NaN if N=NaN.

g(n=0)N

Returns the sign of N-n; -1 if negative, 1 if positive, 0 if N=n, or NaN if N=NaN or n=NaN.

g(a/s)X/S

Returns the element or character in a/s at index N.

g(f)X

Returns the result of passing N though f.

h(n=1)S

Returns N rounded n significant decimals.

i(s)N

Returns an intervalID and evaluates s as JavaScript every N milliseconds.

j(n=1)B

Returns true if N and n are co-prime, or false if not.

k()A

Returns the prime factors of N.

l()N

Returns the factorial of N.

m(n,...,n?)N

Returns the minimum of N and the arguments passed.

n(n=0)N

Returns n-N.

o(n1=0,n2=1,f?)A

Returns the result of passing the integers in the sorted range [n1,N) (with step n2) through f.

p(n=2)N

Returns N raised to the power of n.

q(n=2)N

Returns the nth root of N.

r(n=1)N

Returns N rounded to the nearest multiple of n.

s(n=10)S

Returns N converted from to a base-n string. n is limited to 2-36, inclusive.

s(s/a)S

Returns the result of converting N to a base-s/a string. (e.g., 9.s(["a","b"]) = "baab")

s(f)N

Returns the result of converting N to a string, passing it through f and then converting it back to a number.

s(x=10,f)N

Returns the result of converting N to a base-x string, passing it through f and then converting it back to a number.

t(f)N

Returns an timeoutID and executes f after N milliseconds.

u(n=2)N

Returns N modulo n, always positive.

v(n=2)N

Returns 1 if N is evenly divisible by n, or 0 if not.

w(n,...,n?)N

Returns the maximum of N and the arguments passed.

x(n=0)S

Returns N rounded to n decimal places.

y(n=2)N

Returns the greatest common divisor of N and n.

z(n=2)N

Returns N divided by n and rounded down to the nearest whole number.

à(n?)N

Returns the number of permutations of an array of length N. If n is passed, returns the number of permutations of that array of length n.

â(x?)A

Returns the divisors of N, excluding N if x is truthy.

ç(s=" ")S

Returns s repeated N times.

ì(n/s/a)A

Returns the base-n/s/a digits of N. (e.g., 9.ì(["a","b"]) = ["b","a","a","b"])

ì(f)N

Returns the result of converting N to an array of digits, passing it through f and then converting it back to a number.

ì(x=10,f)N

Returns the result of converting N to an array of base-x digits, passing it through f and then converting it back to a number.

î(s=" ")S

Returns s repeated and sliced to length N.

ò(n1=0,n2=1,f?)A

Returns the result of passing the integers in the sorted range [n1,N] (with step n2) through f.

ó(n1=0,n2=1,f?)A

Returns the result of passing the integers in the sorted range [N,N+n1) (with step n2) through f.

ô(n1=0,n2=1,f?)A

Returns the result of passing the integers in the sorted range [N,N+n1] (with step n2) through f.

õ(n1=1,n2=1,f?)A

Returns the result of passing the integers in the unsorted range [n1,N] (with step n2) through f.

ö(n=1)A/N

Returns n random integers from the range [0,N) with n rounded up to the nearest whole number, if necessary. If n=1 then the integer itself is returned.

ö(x)A

Returns a random permutation of the range [0,N).

Function Methods

a(n=0,f?)N

Returns the first integer >=n that returns a truthy value when passed through F. If f is passed then the value returned by first passing n through f is used instead.

c(n=0,f?)N

Returns the first integer in the sequence n,n-1,n+1,n-2,n+2,n-3,... that returns a truthy value when passed through F. If f is passed then the value returned by first passing n through f is used instead.

f(n=0,f?)N

Returns the first integer >=n that returns a falsey value when passed through F. If f is passed then the value returned by first passing n through f is used instead.

g(n=U,a=[0,1])X

Returns the element in a at index n after repeatedly taking the last element of a, passing it through F and then appending the result to a.

h(n=U,a=[0,1])A

Returns the first n elements of a after repeatedly taking the last element of a, passing it through F and then appending the result to a.

i(n1=0,n2=0)X

Returns the first n1th item, 0-indexed, that returns a truthy value when passed through F, starting with n2.

j(n1=10,n2=0)A

Returns the first n1 items that return a truthy value when passed through F, starting with n2.

Date Methods

K returns the current, local date and time and Ð is the Date constructor, which can accept a Unix timetsamp or date string as a single argument or 2 or more integer arguments for the year, month, day, hours, minutes, seconds and millseconds, respectively.

Methods a-d & f-j below can take up to 2 numeric arguments. The first argument defaults to 0 and returns the value described by the method's description; if 2 is passed instead then the same value is returned after first converting D to universal time (UTC). Passing a value of 1 sets the value in the method's description to the value of the second argument, which defaults to 0, and a value of 3 does the same after, again, converting D to UTC. Setting any part of the date modifies the original D and returns D as a Unix timestamp.

Note that months and weekdays are 0-indexed in JavaScript and, by extension, Japt. See MDN for more details on working with Date objects in JavaScript.

a()N

Returns or sets the milliseconds of D.

b()N

Returns or sets the seconds of D.

c()N

Returns or sets the minutes of D.

d()N

Returns or sets the hours of D.

e()N

Returns the index of the day of the week of D.

f()N

Returns or sets the date of D.

g()N

Returns or sets the month of D.

h()N

Returns or sets the years since 1900 of D. Note that this method has been deprecated in JavaScript.

i()N

Returns or sets the year of D.

j()N

Returns or sets the number of milliseconds in D since January 1, 1970, 00:00:00 UTC.

k()N

Returns the time zone difference in minutes between the local time and UTC.

n(n)N

Returns the result of subtracting D, as a Unix timestamp, from n.

s(n=0)S

Returns D converted to: • a string if n=0, • a date string if n=1, • a time string if n=2, • an ISO string if n=3, • a GMT string if n=4, • a UTC string if n=5, • a locale string if n=6, • a locale date string if n=7, or, • a locale time string if n=8.

Math Methods

a(n1,n2)N

Returns the counterclockwise angle, in radians, between the positive X-axis and the point on the plane at coordinates (n2,n1). Equivalent to JavaScript's Math.atan2 method.

c(n)N

Returns the cosine of n, assuming n to be an angle in radians. Equivalent to JavaScript's Math.cos method.

e(n)N

Returns Euler's Constant raised to the power of n. Equivalent to JavaScript's Math.exp method.

g(n)N

Returns the nth number in the Fibonacci sequence.

h(n/a,...,n/a)N

Returns the result of concatenating all arguments to a single array and calculating the square root of the sum of its squares. Could only accept numeric arguments prior to v1.4.6. Similar to JavaScript's Math.hypot method.

l(n)N

Returns the natural logarithm of n. Equivalent to JavaScript's Math.log method.

m(n)N

Returns the base-2 logarithm of n. Equivalent to JavaScript's Math.log2 method.

n(n)N

Returns the base-10 logarithm of n. Equivalent to JavaScript's Math.log10 method.

q(n=2)N

Returns a random integer from the range [0,n) if n is positive, or [n,0) if n is negative.

q(n1,n2,n3=1)N

Returns a random multiple of n3, relative to n1, from the range [n1,n2).

r(n=1)N

Returns a random float from the range [0,n).

r(n1,n2)N

Returns a random float from the range [n1,n2).

s(n)N

Returns the sine of n, assuming n to be an angle in radians. Equivalent to JavaScript's Math.sin method.

t(n)N

Returns the tangent of n, assuming n to be an angle in radians. Equivalent to JavaScript's Math.tan method.

Other Methods

a(x)n/a

Returns undefined. alerts x.

c(s)S

Returns s compressed.

d(s)S

Returns s decompressed.

g(s,f)X

Returns the contents of URL s after passing them through f.

l(x)n/a

Returns undefined. Logs x to the console.

o(x)n/a

Returns undefined. Writes x to output.

p(x)n/a

Returns undefined. Writes x to output with trailing newline.

q(x)n/a

Returns undefined. Clears the output and writes x.

v(x)X

Returns x evaluated as Japt.

x(x)X

Returns x evaluated as JavaScript.

Flags

Flags can be entered either in the dedicated field or directly in the input box. Some flags may be combined in the form -mR. When a flag runs the programme on each element in the first input and that input is a number then it is first converted to the range [0,N) or, if that input is a string, it is first split into an array of characters and rejoined again afterwards.

-!

Outputs the logical NOT of the value returned by the programme; i.e., true if falsey, or false if truthy.

-E

Outputs an empty string if the programme throws an error.

-E"s"

Outputs s if the programme throws an error. Considered to be a "cheating" flag - use at your own discretion.

-F

Outputs an empty string if the programme returns a falsey value.

-F"s"

Outputs s if the programme returns a falsey value. Considered to be a "cheating" flag - use at your own discretion.

-N

Converts the value returned by the programme to a number. If that value is an array, it is first joined to a string.

-P

Joins the value returned by the programme to a string if that value is an array.

-Q

"Prettyprints" the output.

-R

Joins the value returned by the programme to a string with newlinews if that value is an array.

-S

Joins the value returned by the programme to a string with spaces if that value is an array.

-d

Runs the program on each element in the first input, outputting true if any returns a truthy value, or false if not.

-e

Runs the program on each element in the first input, outputting true if all return a truthy value, or false if not.

-f

Runs the program on each element in the first input, outputting an array of those that return a truthy value.

-g

If the programme returns a number then outputs its sign; -1 if negative, 1 if positive, 0 if 0, or NaN if NaN.

-gn

If the programme returns a string or an array, outputs the character or element at index n, with n defaulting to 0.

-h

If the programme returns a string or an array, outputs the last character or element.

-m

Runs the program on each element in the first input, outputting an array of the results.

-x

Runs the .x() method for the relevant type on the value returned by the programme, trimming a string, reducing an array by addition, or rounding a number to the nearest whole number.

Outputs the value returned by the programme as a boolean; i.e., true if truthy, or false if falsey.

Runs the program on each element in the first input, outputting the first to return a truthy value.

Examples

Warning: if the input field contains a truthy value then the "Truth Machine" example below will initiate an infinite loop of JavaScript alerts.

  1. Hello, World! (14 bytes)
  2. Compressed Hello, World! (11 bytes)
  3. cat (1 byte)
  4. Primality Test (1 byte)
  5. Parity Test (1 byte)
  6. Quine (9 bytes)
  7. FizzBuzz (31 bytes)
  8. Truth Machine (4 bytes)

Settings

Drag and drop the sections below to change the order they appear in the documentation. Changes are saved immediately but will not take effect until the next time you load the interpreter.

  1. Introduction
  2. Interpreter
  3. Japt Basics
  4. Variables
  5. Shortcuts
  6. Compression
  7. Regular Expressions
  8. String Methods
  9. Array Methods
  10. Number Methods
  11. Function Methods
  12. Date Methods
  13. Math Methods
  14. Other Methods
  15. Flags
  16. Examples

Projects

Save Project

My Projects