Skip to content

Instantly share code, notes, and snippets.

@Seggan
Last active January 28, 2023 02:23
Show Gist options
  • Save Seggan/2a3eefa03c299174fc636dac69deb73d to your computer and use it in GitHub Desktop.
Save Seggan/2a3eefa03c299174fc636dac69deb73d to your computer and use it in GitHub Desktop.
Fig operators
char (arity) - desc
whitespace - nop
newline - Starts a new function
! (1) - (any) logical not
" - String literal
# - Misc digraph char
$ (1) - (any) reverse
% (2) - (num, num) b mod a, (str, any) replace % in a with b
& (2) - (num, num) bitwise AND
' - Function ref
( - Loop forever
) - Close variadic operator
* (2) - (num, num) multiply, (str, num) repeat a b times, (num, str) repeat b a times
+ (2) - (num, num) add, (any, any) str(a) + str(b)
, (1) - (any) print with newline, returning the input
- (2) - (num, num) subtract, (str, str) b.replace(a, "")
. - Decimal literal
/ - Single char literal
0 1 2 3 4 5 6 7 8 9 - number literals
: (1) - (any) reverse args of passsed op
; (1) - (any) print without newline, returning the input
< = > (2) - comparison operators
? (3) - (any, any, any) if a truthy, return b, else return c
#? (2) - (any, any) if a truthy, return b, else return a
@ - Operator function reference or 10^num
A (1) - (lst) all truthy? (num) absolute value, (str) to uppercase
B (1) - (lst) convert from binary, (num) to string
C (1) - (num) codepoint to char, (str) char(s) to codepoint(s), (fun) complement of function
D - Open compressed string
#D (1) - (str) compress the input string
E (1) - (num) is even? (lst) pair each item with its index
F (2) - (any, fun) filter a by b, (rgx, any) find the first occurrence of the regex in the other arg, (any, any) filter out a from b
G (2) - (any/fun, fun/any) generate inf. list using initial terms a/b (wrapped in a list if not a list) and generator b/a, (rgx, any) groups of regex matched on the other arg, (any, any) max(a,b)
#G (3) - (any, fun, num) equivalent to t<num>G<any><fun>
H (1) - (num) a / 2, (str) split a in half
I (2) - (any, any) count a in b
J (2) - (lst, any) a.add(b), (lst, lst) a.addAll(b), (any, any) str(a) + str(b)
K (1) - (any) sort increasing
L (1) - (any) length of a
M (2) - (any, fun) map a using b, (fun, fun) map the outputs of b by a. basically returns a new function f(x) = a(b(x)), (any, any) replace all of b with a, (rgx, any) if the regex matches, return the other argument. otherwise, return 0
N (1) - (num) negate, (str) swap case, (fun) call niladic function
O (1) - (num) is a odd? (lst) join by nothing, (fun) set arity to 1
P (3) - (any, lst, fun) apply c to the elements at indexes b in a, (any, num, fun) apply c to element b in a, (str, str, str) transliterate c using a -> b
Q (0) - Last value returned
R (2) - (any, fun) reduce a by b, (num, num) range [a, b)
S (1) - (lst) sum by the + operator, (num) digit sum, (str) sum of charcodes
T (1) - (lst) truthy indexes of a, (fun) set arity to 3, (num) a * 3, (str) a + a + a
U (1) - (any) uniquify
V (1) - (any) set register to a, return input
W (1) - (any) wrap a in a singleton list
X (0) - Self function reference
#X (0) - All inputs as a list
Y (2) - (any, any) interleave
Z (2) - (any, any) zip
[ (1) - (any) first item
\ (2) - (num, num) divide, (any, any) split b on a
] (1) - (any) last item
^ (2) - (any, fun) sort a by b, (num, num) b to the power of a
_ (1) - (num) floor of input, (str) string to number
` (variadic) - List from arguments
a (1) - (lst) any truthy? (str) to lowercase, (num) range [1, a]
b (1) - (num) convert to binary, (str) is alphabetic?
c - Constant digraph char
d (1) - (lst) from digits
e (1) - (any) rearrage the ops so that it vectorises over its last argument
f (1) - (lst) flatten, (num) digits, (str) chars
g (2) - (any, any) min(a,b)
h (1) - (num) a * 2, (str) a + a, (fun) set arity to 2
i (2) - (any, num) a[b], (any, fun) is a invariant when b is applied on it?
j (2) - (lst, any) join list on other bit
#j (1) - (lst) join on newlines
k (1) - (lst) prefixes, (num) factors
l (2) - (any, any) find a in b, (any, fun) apply b on a
#l (1) - (any) is list?
m - Math digraph char
n (3) - (any, num, fun) apply c on every bth element in a
#n (1) - (any) is number?
o (2) - (any, any) remove all a from b, (str, str) overwrite b with a (- exists for performing the former operation on strings), (any, fun) call monadic function b on a
p (1) - (any) discard the first element, (num) is prime?
mp (0) - all primes
q (1) - (any) discard the last element
r (1) - (num) range [0, a), (lst) product
#r (1) - (num) range [0, a]
s (2) - (any, num) discard the first b elements from a, (any, fun) apply b to the first b.arity elements of a, (str, str) equals ignore case
#s (1) - (any) is string?
t (2) - (any, num) take b elements from a, (any, fun) take from a while b(item) is truthy
u (1) - (any) unpack
v (0) - Get register
w (2) - (any, any) return list [a, b] (dyadic ':')
x (0) - Contextual input
#x (0) - Take program's input, irrespective of context
y (1) - (any) uninterleave (returns [a, b])
z (3) - (any, any, fun) map c over a, b, using vectorisation behavior
{ (1) - (num) decrement
| (2) - (num, num) bitwise OR
} (1) - (num) increment
~ (1) - (any) bitwise NOT
cH - Hello, World!
cA - ABCDEFGHIJKLMNOPQRSTUVWXYZ
ca - abcdefghijklmnopqrstuvwxyz
cB - ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz
cC - BCDFGHJKLMNPQRSTVWXZ
cc - bcdfghjklmnpqrstvwxz
cb - BCDFGHJKLMNPQRSTVWXZbcdfghjklmnpqrstvwxz
cV - AEIOU
cv - aeiou
cO - AEIOUaeiou
cY - AEIOUY
cy - aeiouy
co - AEIOUYaeiouy
cd - 0123456789
cN - ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789
cz - reversed alphabet
cZ - reversed upperphabet
cp - printable ASCII
cn - newline
cP - Pi
cE - Euler's number
cG - Phi
mC - Counting numbers
mN - Natrual numbers
mH (1) - (str) from hex, (num) to hex
mM (1) - (num) mean
mQ (1) - (num) square
mq (1) - (num) square root
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment