Skip to content

8.1) Built in Predicates

Julien Cumin edited this page Apr 15, 2019 · 29 revisions

All built-in predicates act like user-defined predicates as described in the previous section: they have one Input variable ? and one Output variable .. However, built-in predicates also have a subscript, which is an additional parameter which can change the behavior of the predicate.

For example, the built-in predicate +, by default, applies the constraint that the sum of the elements of ? must result in .. In that case, the input is necessarily a list. However, the built-in predicate +₁, with subscript , applies the constraint that ? + 1 = . (i.e. incrementation).

It is possible to indicate that a value of ? must be used as a subscript for the predicate, using and (first and last). For example, in ["test",2]∋₎, 2 (the last element of the Input) will be used as subscript for .

A lack of subscript means that the predicate uses its default behavior (which may be the same as the behavior for a specific subscript, see the list below).

Subscript arrow

You can use the subscript arrow to pass the immediately following variable as a subscript to a predicate (like and , in a shorter way that does not require the input to contain that variable).

For example, 13+↙7 will output 14.

List of built-in predicates

Symbol Name Subscript                       Description
Less-equal Default=0
1
? ≤ .
? is a non-decreasing list
Greater-equal Default=0
1
? ≥ .
? is a non-increasing list
Contains Default
I
. contains ?
. contains ? at index I
In Default
I
. is an element of ?
. is the Ith element of ?
Superset Default=0 ? is an ordered subset of .
Subset Default=0 . is an ordered subset of ?
Reverse Default=0 . is the reverse of ?
Call predicate Default
I
Call the current predicate recursively
Call the Ith predicate
Cyclically
permute
counterclockwise
Default=1
I
Cyclically permute ccw once
Cyclically permute ccw I times
Cyclically
permute
clockwise
Default=1
I
Cyclically permute cw once
Cyclically permute cw I times
Root Default=2
I
. × . = ?
Ith root
Ceil Default=0
1
. is the max of ?
. = ceil(?)
Floor Default=0
1
. is the min of ?
. = floor(?)
Range ascending Default=0
1
2
3
4
5
6
. = [0, …, ?]
. = [1, …, ?]
. = [?⌋, …, ?⌉]
. = [?⌋, …, ?⌉ - 1]
. = [?⌋ + 1, …, ?⌉]
. = [0, …, ? - 1]
. = [1, …, ? - 1]
Range descending Default=0
1
2
3
4
5
6
. = [?, …, 0]
. = [?, …, 1]
. = [?⌉, …, ?⌋]
. = [?⌉ - 1, …, ?⌋]
. = [?⌉, …, ?⌋ + 1] . = [? - 1, …, 0]
. = [? - 1, …, 1]
Natural integer Default=0
I
? = . ≥ 0
? = . ≥ I
Integer Default
I
? = . is any integer
? = . ≤ -I
Float Default
I
? = . is a float
Convert ? from int to float .
Different Default All elements of ? = . are different
Identity Default . = ?
÷ Integer division Default=0
I
? = [A,B], . = floor(A/B)
. = floor(?/I)
× Multiply Default
I
. is the product of element of ?
. = ? × I
% Modulo Default=0
I
? = [A,B], . = A mod B
. = ? mod I
* Exp Default=0
1
2
3
4
5
6
7
8
9
10
11
12
13
. = exp(?)
. = ln(?)
. = cos(?)
. = sin(?)
. = tan(?)
. = arccos(?)
. = arcsin(?)
. = arctan(?)
. = cosh(?)
. = sinh(?)
. = tanh(?)
. = arcosh(?)
. = arsinh(?)
. = artanh(?)
+ Plus Default=0
I
. is the sum of elements of ?
. = ? + I
- Minus Default=0
I
. is the difference of elements of ?
. = ? - I
/ Divide Default=0
1
I
? = [A,B], . = A/B
. = 1/?
. = ?/I
< Less Default=0
1
? < .
? is an increasing list
= Equal Default
X
All elements of ? are equal
All elements of ? are X
> Greater Default=0
1
? > .
? is a decreasing list
\ Transpose Default=0 . = ?ᵀ
^ Power Default
I
? = [A,B], . = A^B
. = ?^I
a Adfix Default
0
1
. is an adfix of ?
. is a prefix of ?
. is a suffix of ?
b Behead Default=1
I
. = ? minus the head
. = ? minus the first I elements
c Concatenate Default=0
I
Concatenate ? into .
Concatenate ? into ., length(?) = I
d Duplicates Default=0 . is ? without duplicates
e Default
f Factors Default . is the list of factors of ?
g Group Default=1
I
. = [?]
. = […[?]…] (nested I times)
h Head Default
I
. is the first element of ?
. is the first I elements of ?
i Index Default
1
. = [E,I], E is the Ith element of ?
Same as default but 1-indexed
j Juxtapose Default=2
I
. is ? concatenated with ?
. is ? concatenated I times
k Knife Default=1
I
. = ? minus the tail
. = ? minus the last I elements
l Length Default
I
. is the length of ?
. = ? has length I
m Default
n Default
o Order Default=0
1
. is ? sorted in ascending order
. is ? sorted in descending order
p Permute Default=0 . is a permutation of ?
q Default
r Default
s Substring Default
I
. is a sublist of consecutive elements of ?
. is a sublist of I consecutive elements of ?
t Tail Default
I
. is the last element of ?
. is the last I elements of ?
u Default
v Default
w Write Default=0
1
Write ? to STDOUT. . ignored
? = [A,B], write A with format B
x Xterminate Default=0 ? = [H|T], . is H with elements of T removed
y Default
z Zip Default

0

1

. is elements of ? zipped together, cycles on elements shorter than the longest one
. is elements of ? zipped together, stops once the shortest element is depleted
. is elements of ? zipped together, does not cycle on short elements
To codes Default . is the list of char codes of string ?
Blocks Default . concatenated is ?. All elements of elements of . are equal
Dichotomize Default=2
I
. is ? splitted in half
. is ? splitted in I equal parts
Elements Default . is the list of elements of ?. Automatically vectorizes
Default
To number Default . is the number represented by the string ?
Default
Lowercase Default . is ? lowercased
Default
Split lines Default
1
2
3
. is the list of lines in the string ?
. is ? splitted on spaces
. is ? splitted on spaces and lines
? ṇṇ₁ᵐ .
Occurences Default . is a list of couples [E∈?, number of E in ?]
Random element Default . is a random element of ?
Shuffle Default . is a random permutation of ?
Default
Uppercase Default . is ? uppercased
ṿ Default
Writeln I Like w followed by a linebreak
Default
Default
ȧ Absolute value Default . = abs(?)
Base Default=2
I
. is the list of digits of ? in base 2
. is the list of digits of ? in base I
ċ Coerce Default
1
2
.= ? is a list
. = ? is an integer
. = ? is a string
Prime decomposition Default . is the list of prime factors of ?
ė Default
Factorial Default . is the factorial of ?
ġ Groups Default

I

. is ? splitted into groups of equal length (except maybe the last one)
. is ? splitted into groups of length I (except maybe the last one)
Default
Matrix Default
I
. = ? is a square matrix
. = ? is a I×I matrix
Negate Default . = -I
ȯ Default
Prime Default . = ? is a prime number
Random number Default
1
2
. is a random number in [0, ?]
. is a random number in [0, 1]
. is a random number in [A,B] = ?
Sign Default . is the sign of ?
To string Default . is the number ? cast as a string
Default
Cartesian
product
Default . is the cartesian product of elements of ?
Default
ż Default
Label Default=0

1
Affects an integer to . = ? (or their elements) that matches their constraints
Same as Default but in a random order.