Unofficial Uiuisms

Reverse each row of an array
≡⇌ [1_2_3 4_5_6]
Pad
Get the sum of an array
/+ [1 2 3 4 5]
Pad
Get the product of an array
/× [1 2 3 4 5]
Pad
Get the maximum value in an array
/↥ [1 4 5 3 2]
Pad
Get the minimum value in an array
/↧ [1 4 5 3 2]
Pad
Sort an array
⊏⍏. [1 4 5 3 2]
Pad
Get n numbers between 0 and 1 exclusive
÷⟜⇡ 10
Pad
Get n numbers between 0 and 1 inclusive
÷-1⟜⇡ 11
Pad
Create a zero matrix
↯⟜⊚ 5
Pad
Create an identity matrix
⊞=.⇡ 5
Pad
Create an X matrix
↥⇌.⊞=.⇡ 5
Pad
Create a zero matrix of the same shape as another
≠. [1_1 2_2]
Pad
Create a 0xN matrix
↯0⊚ 2
Pad
Replace all NaNs in an array with a value
↧⊸↥ 0 [1 2 NaN 4 NaN]
Pad
Check if character is numeric [0-9]
×⊓≥≤@0,@9 "hi-5!"
Pad
Check if character is letter [a-zA-Z]
↥∩×∩⊓≥≤@a,@z,@A,@Z "oiCu812α"
Pad
Check if character is alphabetic
⌵± "oiCu812α"
Pad
Check if an array is a palindrome
≍⇌. "racecar"
Pad
Convert a number to a string
°⋕ 17
Pad
Convert a string to a number
⋕ "42"
Pad
Convert a string to a list of code points
-@ "Uiua"
Pad
Convert a list of code points to a string
+@ [85 105 117 97]
Pad
Convert a list to a string
/$"_, _" [10 20 30 40]
Pad
Parse a string as a base 2 number
°⋯⇌-@0 "110"
Pad
Parse a string as a base 3 <= X <= 9 number
/+×ⁿ⇌⇡⧻,⊙-:@0 3 "210"
Pad
Interleave two arrays
♭⍉⊟ [1 2 3 4] [5 6 7 8]
Pad
Intersperse an item between the rows of an array
↘1♭≡⊂ π [1 2 3 4]
Pad
Get the cycling windows of an array
◫⊙⊂⊃⊙∘(↙-1) 3 ⇡7
Pad
Get all permutations of size N
◴≡⍏☇1⇡▽. 3
Pad
Split an array at an index
⊃↙↘ 3 [1 2 3 4 5]
Pad
Insert a value into an array at an index
⍜⊙↻⊂ π 3 [1 2 3 4 5]
Pad
Split an array by a delimiter
⊜□≠, @, "split,this,up"
Pad
Split an array by a delimiter with fill elements
⬚@ ⊜∘≠, @, "split,this,up"
Pad
Split an array by a delimiter keeping empty segments
⊕□⍜▽¯⟜\+=, @, "split,this,,up"
Pad
Split an array into groups of contiguous equal elements
⊜□. [1 1 1 2 2 1 1 4]
Pad
Join a list of boxed strings
/◇⊂ {"a" "bc" "def"}
Pad
Find the nth fibonacci number
⊢⍥(⇌\+):1_0 10
Pad
Find the GCD of two numbers
◌⍢⊃◿∘± 35 360
Pad
Remove all instances of an element from a list
▽≠, 4 [1 4 2 0 5 4 3]
Pad
Remove first instance of an element from an array
⍜↻(↘1)⊸⊗ 4 [1 4 2 0 5 4 3]
Pad
Remove the nth element from an array
⍜↻(↘1) 4 [1 4 2 0 5 4 3]
Pad
Remove all instances of a row from an array
▽¬≡≍,¤ 2_0 [1_4 2_0 5_3 2_0]
Pad
Filter by a fixed predicate
▽ =0◿3 . ⇡10
Pad
Find the most common row in an array
⍜⊛(⊢⍖°⊚) "Hello World!"
Pad
Convert a string to uppercase
⌵ "These are Words"
Pad
Convert a string to lowercase
¯⌵ "These are Words"
Pad
Check if a string is in a list of strings
∊□ "uiua" {"apl" "bqn" "uiua"}
Pad
Trim leading whitespace
▽\↥≠@ . " ← remove these"
Pad
Trim trailing whitespace
▽⍜⇌\↥≠@ . "remove these → "
Pad
Trim prefix-matching characters from a set
▽¬\↧∊, "abc" "ccab ← remove this"
Pad
Trim suffix-matching characters from a set
▽¬⍜⇌\↧∊, "abc" "remove this → bcaa"
Pad
Trim whitespace
▽×⍜⇌∩\↥.≠@ . " abc xyz "
Pad
Upscale a 2d matrix or colored image
30 [0_1 3/4_1/4]
▽⟜≡▽
30 [[0_0_1 0_1_0] [1_0_0 0_0_0]]
▽⟜≡▽
Pad
Linearly interpolate between two values
⍜-× 10 0 0.2
⍜⊙-× 0.2 10 0
Pad
Set the value of an array at an index
⍜⊡◌ 2 1_2_3_4 10
Pad
Create a matrix of random 0s or 1s
⁅⊞⋅⋅⚂.⊚ 5
Pad
Create a matrix of random numbers
⌊×⊞⋅⋅⚂.⊚ 5 10
Pad
Arithmetic mean
÷⧻⟜/+ [85 105 117 97]
Pad
Geometric mean
ⁿ÷:1⧻⟜/× [85 105 117 97]
Pad
Harmonic mean
÷/+⟜⧻÷:1 [85 105 117 97]
Pad
Quadratic mean
√÷⧻⟜/+×. [85 105 117 97]
Pad
Median
÷2/+⊏⊟⊃⌊⌈÷2-1⧻.⊏⍏. [85 105 117 97]
Pad
Dot product
/+× [1 2 3] [4 ¯5 6]
Pad
Cross product
1_2_3 4_5_6
↻2-∩(×↻2):,,
Pad
Matrix product
[7_8_9 10_11_12] [1_2 3_4 5_6]
⍜⍉⊞(/+×)
Pad
Matrix power (Also works with scalars)
4 [1_2 3_4]
⊙◌⍥(⊞(/+×),⍉):⊞=.⇡⧻,
Pad
Repeat a function and collect intermediate results into an array
[⍥(×2.)] 10 1
Pad
Pad an array with 0s
[1_2_3 4_5_6]
↻¯±⟜⬚0↙+2△.
Pad
Complex conjugate
⍜°ℂ¯ +i1
Pad
Cosine
∿+η 1
Pad
Tangent
÷:°∠ 1
Pad
Factorial
/×+1⇡ 5
Pad
Rank of an array
⧻△ [1_2_3_4 5_6_7_8 9_10_11_12]
Pad
Main diagonal of an array
⊡≡↯:⇡/↧⟜⧻△. [1_2_3_4 5_6_7_8 9_10_11_12]
Pad
Convert from base, input in little endian
/+×ⁿ⇡⧻, 3 0_2_1_1
Pad
Corner element of an array
⊢♭ [1_2_3_4 5_6_7_8 9_10_11_12]
Pad
Test if positive integers are prime
=⊢⇌°/×. [2 3 4 5 6 7 8 9 10]
Pad
Inverse modulo m, returns m if it does not exist
⊗1◿:×⇡, 3 7
Pad
Multiplicative order modulo m
⊡1⊚=1◿:ⁿ⇡, 2 7
Pad
Continued fraction to decimal
/(+÷:1)⇌ 2_1_2_1_1_4_1_1_6
Pad
Complex argument
∠°ℂ i
Pad
Successive differences
≡/-◫2 2_3_5_9_4
Pad
Binomial coefficient
/×÷¬⟜+¯⇡ 3 5
Pad
Replace all of one element in a list with another
⍜▽≡⋅∘=, 5 [1 5 8 5 2] 3
Pad
Boxed powerset
⍚▽⋯⇡ⁿ:2⧻⟜¤ [1 5 8 2]
Pad
Irrational number to n terms of continued fraction
⇌◌⍥(⊙⊂÷:1◿1⟜⌊)⊙⊙[] 10 e
Pad
Bitwise XOR
⍜∩⋯⬚0≠ 42 65
Pad
Boxed chunks of array
⊕□⌊÷:⇡⧻, 3 1_4_9_16_25_36_49
Pad
LCM (by thomasip)
÷◌⊃⍢(◿,⊃↥↧)±×
Pad
Intersperse an item between the rows of an array
/(⊂⊂) π [1 2 3 4]
Pad
Smoothstep function, commonly used in computer graphics
/-×2_3ⁿ3_2⊟.↧1↥0
Pad
Join array of strings with space in between
/◇(⊂⊂:@ ) {"Join" "these" "strings"}
Pad
Join array of strings with space in between
/◇(⊂⊂:@\s) {"Join" "these" "strings"}
Pad
Num
123
Pad
Num
9
Pad
Check if a number is perfect
=/+▽≠0.×≠⟜:▽≠0.×⌊:=,⌊.÷+1⇡... 8128
Pad
divisible by
=0◿
Pad
Better "Check if a number is prime"
=1⧻°/× 367
Pad
Check if a number is prime
=2⧻▽≠0.×⌊:=,⌊.÷+1⇡. 37
Pad
Better prime testing
=₀⧻▽⊸=₀◿▽◡˜<+2⇡-1⌈⊸√ 137
Pad
IsEven
=⊃⌊∘÷2 [0 1 2 3 4 5]
Pad
Is number square?
=⊸⁅√ 25
Pad
Format 4byN array as bytes
BYTE ← ( ⤸1 ↯ 8 )
Pad
Encode a string through UTF8 into bits
ENC ← ( utf₈ ⋯ )
Pad
↘⊙(⇡+₁)°⊟ [5 9]
Get whole numbers between n1 to n2 inclusive
Pad
Unencode a string that has been encoded through UTF8 into bits
UNENC ← ( °⋯ °utf₈ )
Pad
return both the min and max of an array
[/↧ ⟜/↥]
Pad
Angle between two vectors in degrees
[1 0 1 0 0] [0 1 0 1 0] ÷τ×360°(∿-⊙η)/+×∩(÷√/+×..)
Pad
Matrix Dot Multiplication (B∙A; B must have same number of columns as A has rows, only tested for rank 2 and 1 matrices)
[12_34 56_78] [1_0 0_1] # A B ≡⌞(/+×) # B∙A
Pad
Split an integer into its digits
[⍥(⊃(⌊÷10)(◿10))⌊ₙ10.]
Pad
Replace 0s in an array with first non-0 value to the left
\(⊡≠0⤙⊟) [1 0 0 2 0 3 0 0 4 5 0]
Pad
/+⍉∵⌕¤1_2_3_4_5 2_4_6_3_5
find multiple items inside a list
Pad
Array Sum
redadd[1 2 3]
Pad
Some value!!
test
Pad
Get the first N rows of an array while maintaining the original, great for box arrays
{"UIUA" "Q" "JPL" "J" "BQN"} ⊸↙1
Pad
Char to Integer (also works with Strings)
°(+@\0) "Hello world!"
Pad
Prime decomposition of N
°/× 100
Pad
Count occurences of each element in an array
°⊚⊛⟜◴ "hello, world"
Pad
Shuffle an array / string
°⍆ "remix"
Pad
Shuffle an array
°⍆ ⇡10
Pad
Get weekday from datetime
°□⊡:Days◿7+4⌊÷86400
Pad
Calculate pi
×4÷⧻⟜/+♭<₁˙⊞(⌵ℂ)-⊸¬÷⟜⇡4000
Pad
Find starts of runs of 1s in a list of 1s and 0s
׬⊸°↻₁
Pad
Round away from 0
×⊃±(⌈⌵)
Pad
Round towards 0
×⊃±(⌊⌵)
Pad
Find start of FIRST run of 1s in a list of 1s and 0s
×⊸◰
Pad
Combinations (choose operation)
÷×∩₃(/×+1⇡)⟜⊸- 3 6 #6 choose 3
Pad
Angle between two vectors in degrees
÷τ×360°(∿-⊙η)/+×∩(÷√/+×..)
Pad
Average value of an array
÷⊃⧻/+
Pad
Normalize vector
÷⍜°√/+.
Pad
Interpolate between two 2d points in an array
÷⟜(≡/+◫)⟜▽/↥⌵/-.
Pad
Average value of an array
÷⧻:/+.
Pad
Half and Half black/white image(INSTANT!)
˙⊞<∠100⇡100
Pad
Blurry half and half black/white image
˙⊞◿∠100⇡100
Pad
Combinations (choose operation)
˜÷÷⊃∩(/× +1⇡)(/× +1⇡-) 3 6 #6 choose 3
Pad
Calculate nPr. F is factorial.
˜÷⊃(⊙◌f)(f˜-)
Pad
Calculate nCr. F is the factorial.
˜÷⊃(⊙◌f)(×⊃(f◌)(f˜-))
Pad
Split an integer into its digits
↘2[⍥(⊃(⌊÷10)(◿10))∞]
Pad
clamp function(min max value_to_be_clamped)
⇅ ← ↥⊙↧
Pad
indexes of matrix
⇡△
Pad
NxM matrix of indexes
⇡△[N M]
Pad
√/+ⁿ2
Pad
Generalizes "Upscale a 2d matrix or colored image" to any rank and shape of array. The first argument describes how each element gets scaled and the second argument contains the array with the arguments
∧(⍉▽) 2_2 ↯4_4⇡16
Pad
Split an array in half (every other element)
∩▽ ⊙, ∩(◿2) +1. ⊸(⇡⧻) [1 2 1 2 1]
Pad
Given a 1 dimensional array it boxes each element individually
∵□₁
Pad
Kronecker product of two matrices
≡/⊂/⊂⊞⊞× [1_2 3_4] [5_6 7_8]
Pad
Take rank-4 matrix of windows and snitch them together into a rank-2 matrix (join axes 1
≡/⊂⤸1≡/⊂⤸1
Pad
Generate an array of all permutations of rows
≡°⍉☇¬⧻.⍉/(≡↻⇡⟜↯⧻.⍣⊟⊂)
Pad
Split an integer into digits (parse method)
≡⋕⍉¤°⋕
Pad
Capitalize a string (can also be done with [first]⊢ instead of [pick]⊡ 0, and [un]°[join]⊂ instead of ⌵⊢.)
⊂:¯⌵↘1:⌵⊡0."HEY there!"
Pad
Split an integer into its digits
⊂⍥(⊙⊂⌊÷10:◿10.)⌊ₙ10.:[]
Pad
Generate array with cardinal directions
⊂⟜¯⋯2_1
Pad
Reverse three elements in the stack
⊃(⊣)(⊢):°⊂⇌[⊙⊙⊙]
Pad
Reverses three items in the stack v2
⊃⊣⊢:°⊂⇌[⊙⊙⊙]
Pad
Sort an array using F which returns a boolean indicating whether the two arguments are in order
⊏ ⍏≡/+⊸(⊞F.)
Pad
Sort an array using F which returns a boolean indicating whether the two arguments are in order
⊏ ⍖ /+ ⊸(⊞F.)
Pad
Compose two permutations
⊏:
Pad
Use the pride flag builtins to make a pride flag
⊏⍉⊞+↯×10⊃⋅∘⊙◌0⟜◿⟜(↻¯5⁅×)⟜(÷⟜⇡×10)⊸⧻ Rainbow
Pad
Shuffle an array
⊏⍏⊸[⍥⚂⧻] "shuffle me!"
Pad
Shuffle an array
⊏⍏⊸≡⋅⚂
Pad
Sort table by column index I, ascending.
⊏⍜⍉(⍏⊡I)
Pad
Shuffle an array with a seed
⊏⤚(⍏gen⧻) "Uiua" 1
Pad
progressive index of
⊗∩(≡□₂⊸⧆)
Pad
Given an adjancy matrix with valid topological sorts, returns a topological sort. If there are any loops, nodes in and downstream of loops will not be included in the output
⊙◌⍢(⊂⊙⊚⊙(⟜(≡↥¤)¬⟜↧/↥.)|/↥¬/↥◌)[]
Pad
Partition a string by a non-scalar delimiter
⊜∘ ¬⦷" - ". "foo - bar - baz"
Pad
Make a diagonal of 2 characters, going from top left to bottom right
⊞(˜⊡" x"=).⇡10
Pad
Make a diagonal of 1s in a 2d array, going from top left to bottom right
⊞=.⇡10
Pad
Get a random value from an array
⊡⌊×⚂:⟜(⧻)[1 2 3 4 5]
Pad
Pivot the axes of an array
⊡⍉⊏⟜⊸(°⍉⇡⊕⊢⊙△) 2_0_1 °△ 5_5_5
Pad
Get all values within a triangle set by two positions
⊡♭₂+⊡0:⇡+1⤚- [StartX StartY] [EndX EndY]
Pad
Find the middle element of an array
⊣⊢⬚0↯2_∞
Pad
Reverse integer digits
⋕∵⇌°⋕[100 101 102]
Pad
Split an integer into digits
⌊[⍢⊃÷₁₀◿₁₀>₉]
Pad
Cotangent
⌝∠1 0.3
Pad
Get the hexadecimal value of a number
⌵⊏⊙HexDigits⇌base₁₆
Pad
Sort an array
⍆ [1 5 4 3]
Pad
Inititalize a random NxM weight matrix in the range [-1, 1]
⍉≡°⍆⍉⍜⊏≡°⍆°⊏⍜⊏≡(ׯ1)⊚◿(+1⌊×(⧻)⚂)⊸°⍆°⊏
Pad
Inititalize a random NxM weight matrix in the range [-1, 1]
⍉≡°⍆⍉⍜⊏≡°⍆°⊏⍜⊏≡(ׯ1)⊚◿(+1⌊×(⧻)⚂)⊸°⍆°⊏gen [N M] Seed
Pad
Matrix multiplication
⍉≡≡(/+/×)⊞⊟⍉
Pad
Generate a random permutation of 0-n
⍏[⍥⚂9]
Pad
Get first letters of a string
⍚⊢⊜□⊸≠@\s "chess battle advanced"
Pad
Delete index of letter in string
⍜(↻|↘1) 1 "cats"
Pad
Find inverse of a permutation
⍜⊏(⇡⧻):⇡⧻.
Pad
Fully reverse array
⍜♭⇌ [69_420 67_21]
Pad
Get first digits of Fibonacci
⍥◡+10 1 1
Pad
Remove rows of an array
▽¬ ⊙◌ ⍜⬚0⊟∘ ⊙°⊏ °⊚ 1_3 "cobra"
Pad
Remove the nth element from an array
▽¬°⊚4 [1 4 2 0 5 4 3]
Pad
Factor of n
▽≠0.×⌊:=,⌊.÷+1⇡. 100
Pad
Remove first instance of an element from an array
▽≠1⊸⦷ 4 [1 4 2 0 5 4 3]
Pad
Factors of number
▽⊸=⊸⁅÷+1⊸⇡ 36
Pad
Create a checkerboard of size N
◿2⊞+.⇡ 8
Pad
Power Set Idiom
⬚{▽0}/(⊂⟜⍚⌟⊂).
Pad
Generate an array of all permutations of rows
⮌+1°⊏⬚(▽0)/(≡↻⇡⟜↯⧻.⊂).
Pad
Pad
Join array of strings with spaces between (without flip)
/◇(⊂˜⊂@ ) {"Hello" "World" "Again!"}
Pad
Shuffle an array
un sort
Pad
Separate out signs and abs values of numbers
°× [2 ¯3]
Pad
Parse a hex color code string "#FF9933"
÷255⇌⬚0↙3⊥₂₅₆⋕₁₆↘1
Pad
Median (Uiua 0.19.0-dev.4)
÷₂/+⊏⊟⊃⌊⌈÷₂-₁⧻⟜⍆ [85 105 117 97]
Pad
Make a diagonal of 1s in a 2d array, going from top left to bottom right, with ˙ (self) instead of . (duplicate, deprecated)
˙⊞=⇡10
Pad
Create an identity matrix
˙⊞=⇡5
Pad
swap stack top
˜∩∘
Pad
Get proper divisors of N (does not include N itself)
↘¯1▽=0⤚◿⊸⇡₁
Pad
Exclusive range from a to b
↘±-◠⍜-⇡
Pad
Split an integer into its digits
↘₁⇌⍥(⌊÷10⤙◿10) ∞
Pad
Generate a list of points within a particular range. For example, (F [1 1] [2 2]) returns [2_2 2_1 1_2 1_1].
↯⍜(↘¯1|/×)△.˜(+⟜(⇡-)+1)
Pad
Zip (or zipWith) two arrays with a binary operation (here the op is $"_ _"); the pattern is ≡(°⊟)⍉⊟; ≡ may need to be replaced with ⍚
≡($"_ _" °⊟)⍉⊟ ⇡5 ⇌⇡5
Pad
Get neighbours in 2D array
≡₁(□▽⊸≠∞)⍉⊸⬚∞↻A₂ °△[3 5]
Pad
Split number and trailing text into two variables
⊃(⋅⊙◌|↘⊙⋅∘)⧻⊸⊥₁₀⊢⊸⊜⋕⊸(∊"0123456789")"123abc"
Pad
every other value of array
⊃(▽⋅⊙|▽⊙⋅) ⟜¬ ◿₂ ⊸(⇡⧻) [1 2 1 2 1] ### [1 1 1] [2 2]
Pad
Find the first non-blank word
⊏+⊃⊢(⇡/-)↙2⊚≠⊸⬚0↻¯1⊸≠@ " this is a test"
Pad
Set values at indices within a target matrix. It takes three arguments: 1) an array of points for the indices to replace; 2) the original matrix; 3) the value to set the given indices to.
⊙◌∧(⊸⍜⊡◌⊙°□)⊙□
Pad
Set a submatrix within a target matrix to a paticular value. For example, if (F [1_1 2_2] °△[4 4] 1000) returns [0_1_2_3 4_1000_1000_7 8_1000_1000_11 12_13_14_15].
⊙◌∧(⊸⍜⊡◌⊙°□)⊙□↯⍜(↘¯ 1|/×)△.˜(+⟜(⇡-)+1)⊃⊢(⊏1)
Pad
readlines standard input into an array of boxes
⊙◌⍢(□|⊸(¬≍0)
Pad
Get proper divisors of N (does not include N itself)
⊚=0◿⊸⇡
Pad
Biggest Prime factor of N
⊣°/×
Pad
Bitwise AND
⍜∩⋯⬚0×
Pad
Bitwise OR
⍜∩⋯⬚0↥
Pad
Bitwise AND
⍜∩⋯⬚0↧
Pad
Replace the first element of an array
⍜⊢◌[1 2 3] 5
Pad
Interleave two arrays of different sizes
▽¬⊸⌕NaN♭⍉⬚NaN ⊟ ⇡₁3 ⇡₄7
Pad
Add your own uiuism! (Please be kind!)
You are visitor no. 9946