Skip to content

Instantly share code, notes, and snippets.

@chunkybanana
Created April 22, 2022 10:59
Show Gist options
  • Save chunkybanana/4d50d64c2949e850bce70f677c14d56a to your computer and use it in GitHub Desktop.
Save chunkybanana/4d50d64c2949e850bce70f677c14d56a to your computer and use it in GitHub Desktop.
! 1 factorial Take the factorial of a number, vectorising
" S string delimeter Syntax sugar for a string, actually a number list
# 1 length Length of a list
$ 1 sublists Sublists of a list
% 2 modulo Take the modulo of two numbers, vectorising
& 2 bitwise and Take the bitwise and of two numbers, vectorising
' Q map / zipwith Map a function over a list, or zip two lists and perform a dyadic operation on each pair
( 1 prefixes Prefixes of a list
) 1 suffixes Suffixes of a list
* 2 power Exponentiate one number to another, vectorising
+ 2 add Add two numbers, vectorising
, 2 append Append a list / number to a list
- 2 sub Subtract two numbers, vectorising
. S decimal point The decimal point in a number
/ 2 repeat Repeat a value a number of times
0 S zero Literal digit zero, part of a number
1 S one Literal digit one, part of a number
2 S two Literal digit two, part of a number
3 S three Literal digit three, part of a number
4 S four Literal digit four, part of a number
5 S five Literal digit five, part of a number
6 S six Literal digit six, part of a number
7 S seven Literal digit seven, part of a number
8 S eight Literal digit eight, part of a number
9 S nine Literal digit nine, part of a number
:* 2 matrix power Take the matrix power of a matrix
:< 2 bitshift left Shift a number left by a number of bits, vectorising
:> 2 bitshift right Shift a number right by a number of bits, vectorising
:j 2 to complex Convert a number to a complex number
:Ȧ 2 atan2 Given two arguments, return the arctangent of the quotient of the two arguments
:• 2 matrix multiplication Multiply two matrices
;$ 1 sublists of permutations Sublists of permutations
;1 1 build a matrix with 1s at indicies Build a matrix with 1s at indicies
;A 1 arccos Arccosine of a number, vectorising
;C 1 cos Cosine of a number, vectorising
;D 1 determinant Determinant of a matrix
;F 1 prime factors Prime factors of a number, vectorising
;G 1 graph adjacency matrix Graph adjacency matrix of a graph
;I 1 identity matrix Identity matrix of a given size
;J 1 split complex Split a complex number into its real and imaginary parts
;L 1 natural log Natural log of a number, vectorising
;M 1 mean Mean of a list
;P 1 polyroots Roots of a polynomial
;R 1 range from 2.. n Range from 2 to n
;S 1 sin Sine of a number, vectorising
;T 1 tan Tangent of a number, vectorising
;b 1 boolean matrix to braille Boolean matrix to braille
;c 1 cosh Cosine hyperbolic of a number, vectorising
;f 1 nth fibonacci number Nth fibonacci number
;l 1 nth lucas number Nth lucas number
;m 1 Mirror Mirror a list
;r 1 range from 0...n Range from 0 to n
;s 1 sinh Sine hyperbolic of a number, vectorising
;t 1 tanh Tangent hyperbolic of a number, vectorising
;° 1 degrees to radians Convert degrees to radians
;² 1 is perfect square Is a number a perfect square
;Ċ 1 sec Secant of a number, vectorising
;ċ 1 nth catalan number Nth catalan number
;Ġ 1 graph distance matrix Graph distance matrix of a graph
;Ȧ 1 arctan Arctangent of a number, vectorising
;Ḃ 1 bounce depth 1 Mirror a list, vectorising at depth 1
;Ṗ 1 primes Primes up to a number
;Ṡ 1 csc Cosecant of a number, vectorising
;Ṫ 1 cot Cotangent of a number, vectorising
;Ạ 1 arcsin Arcsine of a number, vectorising
;√ 1 integer square root Integer square root of a number
< 2 less Less than
= 2 equal Equal
> 2 more More than
? 1 random floats Random float between 0 and 1
A 1 absolute value Absolute value of a number, vectorising
B 1 to binary Convert a number to binary
C 1 complement Complement of a number, vectorising
D 1 to digits Convert a number to digits
E 1 all equal All equal
F 1 flatten Flatten a list
G 1 group equal elements by indicies Group equal elements by indicies
H 1 head popping Remove the first item of a list
I 1 increments Differences between successive elements of a list
J 1 range of length Range from 0 to length of a list
K 1 cumulative sum Cumulative sum of a list
L 1 last popping Remove the last item of a list
M 1 square Square a number, vectorising
N 1 neck Neck of a list
O 1 identity Do nothing
P 1 permutations Permutations of a list
Q 1 half Halve a number
R 1 reverse on depth 1 Reverse a list, vectorising at depth 1
S 1 sort Sort a list
T 1 tail Remove the last item of a list
U 1 unique Unique elements of a list
V 1 is prime Is a number prime
W 1 where Generate a list where each value in the first list becomes that many copies of its index
X 1 split into 2 Split a list into two lists
Y 1 elements at even indicies Elements at even indicies of a list
Z 1 transpose Transpose a matrix
[ S start list Start a list
\ 1 unrepeat Lengths of runs of identical values
] S end list End a list
^ 2 bitwise xor Take the bitwise xor of two numbers, vectorising
_( 0 "()"
_+ 0 [1,-1]
_- 0 [-1,1]
_/ 0 "/\\"
_0 0 [0,0]
_1 0 [1,1]
_2 0 [2,2]
_< 0 "<>"
_A 0 "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
_D 0 [[0,1],[1,0],[0,-1],[-1,0]]
_H 0 "Hello, World!"
_P 0 phi
_R 0 printable ascii
_S 0 ඞ
_V 0 "AEIOU"
_W 0 "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789_"
_Y 0 "AEIOUY"
_[ 0 "[]"
_a 0 "abcdefghijklmnopqrstuvwxyz"
_d 0 [[1,1],[1,0],[1,-1],[0,1],[0,0],[0,-1],[-1,1],[-1,0],[-1,-1]]
_e 0 e
_h 0 "hello world"
_p 0 pi
_v 0 "aeiou"
_x 0 "0123456789abcdef"
_y 0 "aeiouy"
_{ 0 "{}"
_Ạ 0 "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz"
_₀ 0 128
_₁ 0 256
_₂ 0 512
_₃ 0 1024
_₄ 0 2048
_₅ 0 4096
_₆ 0 8192
_₇ 0 4294967296
_∞ 0 infinity
` Q scanl1 Scan left by a function
a 2 and Logical and
b 2 to base Convert a number to a base
c 2 binomial coefficient Binomial coefficient of two numbers
d 2 divmod Divide and modulo two numbers
e 2 join each of one to other
f 2 filter drop Remove elements from a list which are in another
g 2 gcd Greatest common divisor of two numbers
h 2 head First n items of a list
i 2 index into Index into a list
j S complex number delimeter Complex number delimeter e.g 1j2
l 2 lcm Least common multiple of two numbers
m 2 min Minimum of two numbers
n 2 floor div Floor division of two numbers
o 2 split at occurence Split a list on a certain value
p 2 pick
q 2 quit
r 2 range inclusive Inclusive range betwen two numbers
s 2 split into chunks Split a list into chunks of a certain length
t 2 tail Last n items of a list
u 2 find for each Find a value in a list for each value in another list
v 2 or Logical or
w 2 windows Sliding windows of a list of a certain length
x 2 max Maximum of two numbers
y 2 join Join two lists
z 2 zip Zip two lists together
{ 1 decrement Decrement a number, vectorising
| 2 bitwise or Take the bitwise or of two numbers, vectorising
} 1 increment Increment a number, vectorising
~ 1 bitwise not Take the bitwise not of a number, vectorising
¨ Q quick map Map a function over a list
¬ 1 not Logical not
¯ S negative number Prefix to signify a negative number, e.g ¯1. works with decimals / complex
° Q apply at Apply a function at a certain index
± 1 sign Sign of a number, vectorising
² Q previous chain as dyad ???
³ Q next chain as nilad ???
´ Q foldl1 Fold left by a function
¹ Q previous chain as monad Turn the previous chain into a monad
Ç 1 split into chunks of length 2 Split a list into chunks of length 2
Ð 1 double Double a number, vectorising
× 2 mul Multiply two numbers, vectorising
÷ 2 divide Divide two numbers, vectorising
Ă 1 any and all - return 0 if z is empty, or contains a falsey value when flattened, else 1.
Ċ 1 choose random Choose a random element from a list
ċ 2 count occerence Replace each value with the cumulative count of that value in the list
Ġ 1 group adjacent equal Group adjacent equal elements of a list
Ń 1 split on newlines Split a list on newlines
Ň 1 join on newlines Join a list on newlines
Ś 1 split on spaces Split a list on spaces
Š 1 join on spaces Join a list on spaces
Ż 1 prepend zero Prepend a zero to a list
ż 2 transpose with filler Transpose a matrix with filler
Ȧ 1 any Return 1 if any element of a list is true, else 0.
ʲ Q scan fixedpoint Scan a list by a function, returning the fixedpoint of the function
ˀ Q ternary if Ternary if - ˀ<cond><truthy><falsy>
˘ Q self args / monad as dyad using left
˙ Q 2 links as nilad
˜ Q swap args / monad as dyad using right
˝ Q foldl
ˢ Q sort
Π 1 product
Σ 1 sum
φ 1 flatten 1 depth
ᐣ Q n-compose
ᴰ Q 2 links as dyad
ᴹ Q 2 links as monad
ᴺ Q all neighbours
ᵀ Q truthy indices after applying
ᵂ Q while
ᵈ Q 3 links as dyad
ᵍ Q filter drop
ᵐ Q 3 links as monad
ᵔ Q apply to neighbours
ᵖ Q Map over prefixes
ᵗ Q apply transpose apply again
ᵝ Q call self
ᵟ` Q scanr1
ᵟ´ Q foldr1
ᵟ˝ Q foldr
ᵟᵂ Q cumulative while
ᵟᵍ Q filter drop of permutations
ᵟᶠ Q filter keep of permutations
ᵟ‶ Q scanr
ᵟⁿ Q cumulative repeat n times
ᵠ Q 4 links as dyad
ᶠ Q filter keep
ᶲ Q 4 links as monad
Ḃ 1 from binary Convert a binary number to a number
ḃ 2 from base Convert a number from a base
Ḅ 1 bit Take a number modulo 2
Ḋ 1 from digits Convert a list of digits to a number
Ḍ 1 divisors Return the divisors of a number
ḍ 2 is divisible Return 1 if a number is divisible by another, else 0.
Ḟ 1 indices of falsey Return the indices of falsey elements in a list
ḟ 2 filter keep Keep elements from a list which are in another
Ḳ 1 sum depth 1 Sum a list of numbers, vectorising at depth 1
ḷ 2 find all Find all occurences of one value in a list
Ṅ 1 negate Negate a number, vectorising
Ṗ 1 print Print a list
Ṙ 1 reverse Reverse a list
ṙ 2 range exclusive Exclusive range between two numbers
Ṛ 1 reciprocal Reciprocal of a number, vectorising
Ṡ 1 reverse sort Reverse sort a list
Ṫ 1 indicies of truthy Return the indices of truthy elements in a list
Ẏ 1 elements at odd indicies Return the elements at odd indicies of a list
Ẓ 1 zip with filler 0 Zip a list with filler 0
Ạ 1 all Return 1 if all elements of a list are true, else 0.
ị 2 find Find a value in a list
Ọ 1 reverse every other Reverse every other element of a list
ọ 2 order
‘ Q each right
’ Q each left
• 2 cartesian product Cartesian product of two lists
‶ Q scanl
⁰ Q previous chain as nilad
ⁱ Q fold fixedpoint
⁴ Q next chain as monad
⁵ Q next chain as dyad
⁶ Q chain at
⁷ Q set register Set the register to a value
⁺ Q max
⁻ Q min
⁼ Q is equal after applying
ⁿ Q repeat n times
₀ 0 100 / 1st arg First CLI argument or 100
₁ 0 [0,1] / 2nd arg Second CLI argument or [0,1]
₂ 0 10 / 3rd arg Third CLI argument or 10
₃ 0 16 / 4th arg Fourth CLI argument or 16
₄ 0 32 / 5th arg Fifth CLI argument or 32
₅ 0 64 / 6th arg Sixth CLI argument or 64
₆ 0 26 / 7th arg Seventh CLI argument or 26
₇ 0 get register get the value of the register
₈ 0 read a character Read a character from stdin
₉ 0 read a line Read a line from stdin
₊ S next 2 as string Return the next two characters as a string
₋ S next as string Return the next character as a string
₍ 0 chains left argument Return the chains left argument
₎ 0 chains right argument Return the chains right argument
∆ 1 maximum Maximum of a list
∇ 1 minimum Minimum of a list
∊ 2 in Return 1 if a value is in a list, else 0.
√ 1 square root Square root of a number, vectorising
≠ 2 not equal Return 1 if two numbers are not equal, else 0.
≡ 2 strictly equal Are two values equal?
≢ 2 strictly not equal Are two values not equal?
≤ 2 less or equal
≥ 2 more or equal Is one number greater than or equal to the other?
⊂ 1 enclose Wrap a value in a list
⊆ 1 enclose if not Wrap a value in a list if it is not in a list
⊏ 2 everyth element Every nth element of a list
⊢ 2 right Right argument
⊣ 2 left Left argument
⋈ 2 pair Pair two values
⌈ 1 ceil Ceiling of a number / real part of a complex number, vectorising
⌊ 1 floor Floor of a number / imaginary part of a complex number, vectorising
⌜ Q outer product
⌽ 2 rotate
⍋ 1 grade up Indices of a list sorted by their values
⍒ 1 grade down Indices of a list sorted by their values, reversed
⍝ S comment Comment out whatever comes next
⍪ 2 prepend Prepend one value to another
⍳ 1 iota Given a list of dimensions, generate a matrix where each value is its coordinate in the matrix
⍴ 2 reshape
⍸ 1 range from 1...n Range from 1...n
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment