-
Notifications
You must be signed in to change notification settings - Fork 5
8.1) Built in Predicates
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).
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 20.
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 I th 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 I th 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
|
. × . = ? I th 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 I th 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 2 3 4/5/6/7 |
Write ? to STDOUT . . ignored ?=[A,B] , write A with format B . . ignored Same as 0 with ? = . Same as 1 with ? = . Like 0/1/2/3 respectively, but it will only print at the end of the main predicate, meaning printed variables with those subscripts can be further constrained after the actual call to write in the program. |
x |
Xterminate | Default=0 |
? = [H|T] , . is H with elements of T removed |
y |
Default | ||
z |
Zip | Default 0 1 2 |
. 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 Same as default but ensures that all elements of ? have the same length |
ạ |
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 | . = -? |
ȯ |
Default | ||
ṗ |
Prime | Default |
. = ? is a prime number |
ṙ |
Random number | Default 1 2 |
. is a random number in [0, ?] (if ? is an integer, then . is an integer; if ? is a float, then . is a float) (this holds for all subscripts) . 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. |