-
Notifications
You must be signed in to change notification settings - Fork 0
Functions
This page specifies all the functions in Catholicon, and what arguments they take. Inputs are automatically coerced to the required type if possible, but output types are strict. x specifies the first argument to a function, y the second. Valid types are: any, str, num, int, flt, bool, atom, list[], tuple[], stream[], fun(), escape(), two_char(). Most functions are vectorisable if reasonably possible.
The difference between fun()
and escape()
is that fun()
is an Elixir anonymous function, and escape()
is a function represented by the code. two_char() means the function uses the next character in the code.
Name | Spec | Function |
---|---|---|
² |
num -> num |
Square; x * x |
√ |
num -> flt |
Square root. |
≠ |
any, any -> bool |
x != y |
½ |
num -> num |
Halve. |
Ȧ |
str, str -> str |
Concatenate x with y. |
Ḃ |
any, any -> list[any, any] |
Yields a list with the two arguments as its contents |
Ċ |
-> any |
Retrieves and evaluates a line of input. |
Ḋ |
num -> flt |
Increment. |
Ė |
str, int |
Convert y from base x to base 10. |
Ḟ |
int, int |
Convert y from base 10 to base x. |
Ġ |
str -> str |
Removes the first character of x. |
Ḣ |
int -> list[int] |
0..x |
İ |
int -> list[int] |
1..x |
Ŀ |
int, int -> list[int] |
x..y |
Ṁ |
list[any] -> any |
Picks a random element from x. |
Ṅ |
int -> list[int] |
Digits. |
Ȯ |
list[int] -> int |
Undigits. |
Ṗ |
list[num] -> num |
Sum. |
Ṙ |
list[num] -> num |
Product. |
Ṡ |
str -> int |
Convert x from base 2 to base 10. |
Ṫ |
int -> str |
Convert x from base 10 to base 2. |
Ẇ |
int -> bool |
Is even? |
Ẋ |
int -> bool |
Is odd? |
Ẏ |
num -> num |
Decrement. |
Ż |
int -> int |
Bit count; count the number of one bits in the binary representation of x. |
A |
any -> any |
Assign x to the variable A. |
B |
-> any |
Read variable A (default: 16) |
C |
-> int |
Read the last literal integer created. Example: +10C is 20 (default: 36) |
D |
-> any |
Read the current value in a loop (default: -1) |
E |
-> int |
10 |
F |
-> int |
100 |
G |
-> int |
1000 |
H |
-> any |
The first input |
I |
-> int |
500. |
a |
num -> num |
1 - x |
b |
-> flt |
Returns a uniformly random number [0, 1) |
c |
-> flt |
Returns a normal deviate float - that is, the mean is 0 and the standard deviation is 1. |
d |
str -> bool |
Is empty? |
e |
str -> any |
Evaluate. |
f |
list[any] -> list[any] |
Prepend 0 . |
g |
int -> int |
x mod 2. |
h |
any -> any |
2 to the power of x. |
i |
int -> bool |
Is prime? |
j |
int, int -> int |
Bitwise AND. |
k |
int, int -> int |
Arithmetic left bitshift. |
l |
int, int -> int |
Arithmetic right bitshift. |
m |
int, int -> int |
Bitwise XOR. |
n |
int, int -> int |
Bitwise OR. |
o |
int -> int |
Bitwise NOT. |
p |
bool, bool -> bool |
Boolean AND. x && y |
q |
bool, bool -> bool |
Boolean OR. x || y |
r |
bool -> bool |
Boolean NOT. !x |
s |
list[any] -> list[list[any]] |
Permutations |
t |
int, list[any] |
Permutations of length x |
|
any -> any |
Yield; return x. Can be used to separate arguments (ie Ȧ1 2 is 12 ) |
! |
escape(-> any) -> any |
Execute x until it returns the same value twice in a row. In replacement for the lack of a value, uses the previous value or the input for the first exeuction. |
# |
any -> fun |
Convert x into a function. |
$ |
fun -> any |
Run the function x. |
$ |
str -> str |
Upcase. |
& |
escape(-> any) -> fun(-> any) |
Escape. Example: $%1 returns 1, as %1 returns fn -> 1 and $ evaluatates it. This is different to # as does not evaluate the code, and instead escapes it. It is then evaluated when the method is called. |
% |
int, int -> int |
Modulo. |
' |
escape(-> any) -> str |
Convert to a string. |
( |
any -> any |
Print with newline. |
) |
any -> any |
Print without newline. |
* |
num, num -> num |
Multiply. |
+ |
num, num -> num |
Add. |
, |
num -> num |
Multiply by 1000. |
- |
num, num -> num |
Subtract. |
. |
num -> num |
Divide by 100. |
) |
any -> any |
Print without newline. |
/ |
num, num -> num |
Divide. |
: |
list[any], list[any] -> list[any] |
List concatenate. |
; |
list[any], list[any] -> list[any] |
List subtraction; removes the first occurrence of an item in x for each item in y. |
< |
num, num -> bool |
Less than? |
= |
any, any -> bool |
x == y |
> |
num, num -> bool |
Greater than? |
? |
two_char() -> str |
Get the next character literally. |
@ |
escape(-> any) -> str |
Codepoints. |
_ |
to_char(any) -> any |
Two character monads - see below. |
` |
two_char() -> any |
Two character nilads - see below. |
ȧ |
int, int -> int |
GCD. |
ḃ |
num -> num |
Absolute. |
ċ |
num -> int |
Ceil. |
ḋ |
num -> int |
Floor. |
ė |
num -> int |
Round. |
ḟ |
str -> str |
Uppercase the first character and lowercase the rest |
ġ |
str -> str |
Downcase. |
ḣ |
str -> str |
Trim; remove leading and trailing whitespace. |
ṁ |
flt -> str |
Returns a fraction in its most simplified form as a string, ie ṁ"0.5" is 1/2 . |
ṅ |
str -> flt |
Split by / and divide. Example: ė"4/5" is 0.8 . |
ȯ |
str, str -> list[str] |
Split x on y. |
ṗ |
str, str -> int |
Count the amount of times y appears in x. |
ṙ |
str, int -> str |
Get the character at element y modulo the length of x in x. |
ṡ |
any -> int |
Length. |
ṫ |
num, escape(num -> bool) -> list[num] |
Decompose x into the largest values matching y. Example: ṫ35ẇ√ -> decompose(35, num -> is_whole_num(sqrt(num))) decomposes into square numbers and returns [25, 9, 1]
|
ẇ |
num -> bool |
Is whole number? |
ẋ |
list[any], escape(any -> any) -> list[any] |
Map each element of the x by y. |
ẏ |
str, int -> str |
Pad x by leading spaces to length y. |
ż |
str, int -> str |
Pad x by trailing spaces to length y. |
Ạ |
-> str |
abcdefghijklmnopqrstuvwxyz |
Ḅ |
-> str |
ABCDEFGHIJKLMNOPQRSTUVWXYZ |
Ḍ |
-> str |
bcdfghjklmnpqrstvwxyz |
Ẹ |
-> str |
aeiou |
Γ |
str, str, str -> str |
Replace. |
π |
-> num |
Pi - 3.141592... |
ρ |
num, escape(num -> bool) -> num |
Nth-that-matches; returns the nth integer for which the function returns true (0-indexed) |
σ |
num, escape(num -> bool) -> num |
Above, but 1-indexed. |
τ |
-> num |
Tau - 6.28318... |
φ |
-> num |
Golden ratio - 1.61803... |
Ǎ |
int -> int |
Factorial. |
Č |
num, num -> num |
Maximum. |
Ď |
num, num -> num |
Minimum. |
Ě |
num, num -> num |
Power. |
Ǧ |
num -> int |
Square root, then floor. |
Ǐ |
int, int -> int |
LCM. |
Ǩ |
str -> str |
Decode from base 16. |
Ľ |
str -> str |
Encode into base 16. |
Ň |
str -> str |
Decode from base 32. |
Ǒ |
str -> str |
Encode into base 32. |
Ř |
str -> str |
Decode from base 64. |
Š |
str -> str |
Encode into base 64. |
Ť |
list[any] -> list[any] |
Reverse. |
Ǔ |
num -> num |
Double. |
Ž |
int, list[any] -> any |
Get the element x in the list y. Can vectorise to getting multiple elements in a list. |
ǎ |
any -> list[any] |
Group by consecutive equal elements / group adjacent |
č |
list[num] -> list[num] |
Cumulative sum. |
ď |
list[any] -> list[any] |
Flattens a list of nested lists. |
ě |
list[any] -> escape(any -> any) |
Reduce by the implicit variable and the loop variable. |
ǧ |
int -> list[int] |
Prime factors. |
ȟ |
list[any] -> any |
Head; get the first element |
ǐ |
list[any] -> list[any] |
Tail; get everything but the first element. |
ǰ |
list[num] -> list[num] |
Deltas; differences between elements. |
ǩ |
list[any] -> any |
Maximum. |
ľ |
list[any] -> any |
Minimum. |
ň |
two_char(), list[any] -> list[any] |
Map over the next character. ňṡ finds the length of each element in y (but you can also use ř ) |
ǒ |
list[any], int |
Duplicate each element of x, y times. |
ř |
list[list[any]] |
Length of each for each in x. |
š |
list[any], any -> any |
Count the amount of y in x. |
ť |
str -> list[str] |
Graphemes (characters). |
ǔ |
str, str -> bool |
y contains x |
‰ |
num -> num |
Per-mille; divide by 1000. |
≤ |
num, num -> bool |
Less than or equal to? |
≥ |
num, num -> bool |
Greater or equal to? |
≣ |
any, any -> bool |
x === y |
㎳ |
-> int |
OS time in milliseconds. Note that this is a single character. |
δ |
any -> bool |
If x, then 1, else 0. |
~ |
n/a | Close escaped code. Example: ='a~?a -> =('a~, ?a) results in true . |
Name | Value |
---|---|
`Ȧ |
16 |
`Ḃ |
32 |
`Ċ |
64 |
`Ḋ |
abcdefghijklmnopqrstuvwxyz |
`Ė |
3.141592653589793 |
`Ġ |
1.618033988749895 |
`Ḟ |
6.283185307179586 |
`Ḣ |
27 |
`İ |
28 - 1 |
`J̇ |
28 |
`K̇ |
29 |
`L̇ |
210 |
`Ṁ |
211 |
`Ṅ |
215 |
`Ȯ |
216 |
`Ṗ |
231 |
`Q̇ |
232 |
`Ṙ |
263 |
`Ṡ |
264 |
`Ṫ |
1/3 |
`U̇ |
1/4 |
`V̇ |
1/5 |
`Ẇ |
2/3 |
`Ẋ |
3/4 |
`Ẏ |
2/5 |
`Ż |
3/5 |
`ȧ |
4/5 |
`ḃ |
16 |
Name | Spec | Value |
---|---|---|
_Ȧ |
num -> num |
x * 10 |
_Ḃ |
num -> num |
acos(x) |
_Ċ |
num -> num |
acosh(x) |
_Ḋ |
num -> num |
asin(x) |
_Ė |
num -> num |
asinh(x) |
_Ḟ |
num -> num |
atan(x) |
_Ġ |
num -> num |
atanh(x) |
_Ḣ |
num -> num |
cos(x) |
_İ |
num -> num |
cosh(x) |
_J̇ |
num -> num |
erf(x) - error function |
_K̇ |
num -> num |
erfc(x) - 1-erf(x) |
_L̇ |
num -> num |
exp(x) |
_Ṁ |
num -> num |
log(x) |
_Ṅ |
num -> num |
log10(x) |
_Ȯ |
num -> num |
log2(x) |
_Ṗ |
num -> num |
sin(x) |
_Q̇ |
num -> num |
sinh(x) |
_Ṙ |
num -> num |
tan(x) |
_Ṡ |
num -> num |
tanh(x) |
_Ṫ |
str -> atom |
Convert to an atom. |
You can also represent positive integers by typing them in normally. Ḋ99
is 100
.
Strings can be represented with double quote marks: Ȧ"a""b"
is ab
.