Uiua: Difference between revisions
(Fix some links; remove links that don't make sense for APL Wiki pages (particularly stack ops)) |
m (Don't center the tables; shorten some long rows) |
||
Line 35: | Line 35: | ||
==== Stack ==== | ==== Stack ==== | ||
Work with the stack | Work with the stack | ||
{| class="wikitable | {| class="wikitable" | ||
|+ Table of Stack function in Uiua | |+ Table of Stack function in Uiua | ||
|- | |- | ||
Line 69: | Line 69: | ||
==== Monadic Pervasive ==== | ==== Monadic Pervasive ==== | ||
Operate on every element in an array | Operate on every element in an array | ||
{| class="wikitable | {| class="wikitable" | ||
|+ Table of Monadic Pervasive in Uiua | |+ Table of Monadic Pervasive in Uiua | ||
! Glyph !! Name !! Definition | ! Glyph !! Name !! Definition | ||
Line 93: | Line 93: | ||
==== Dyadic Pervasive ==== | ==== Dyadic Pervasive ==== | ||
Operate on every pair of elements in two arrays (Note that True is 1 and False is 0) | Operate on every pair of elements in two arrays (Note that True is 1 and False is 0) | ||
{| class="wikitable | {| class="wikitable" | ||
|+ Table of Monadic Pervasive in Uiua | |+ Table of Monadic Pervasive in Uiua | ||
! Glyph !! Name !! Definition !! Formats from: | ! Glyph !! Name !! Definition !! Formats from: | ||
Line 129: | Line 129: | ||
| <code>∠</code> || Atangent || Take the arctangent of two numbers || atan | | <code>∠</code> || Atangent || Take the arctangent of two numbers || atan | ||
|- | |- | ||
| <code>ℂ</code> || [[Complex (function)|Complex]] || Make a complex number | | <code>ℂ</code> || [[Complex (function)|Complex]] || Make a complex number from imaginary and real parts || com | ||
|} | |} | ||
==== Monadic Array ==== | ==== Monadic Array ==== | ||
Operate on a single array | Operate on a single array | ||
{| class="wikitable | {| class="wikitable" | ||
|+ Table of Monadic Array in Uiua | |+ Table of Monadic Array in Uiua | ||
! Glyph !! Name !! Definition | ! Glyph !! Name !! Definition | ||
Line 167: | Line 167: | ||
| <code>◰</code> || [[Nub Sieve|Unique]] || Get a mask of first occurrences of items in an array | | <code>◰</code> || [[Nub Sieve|Unique]] || Get a mask of first occurrences of items in an array | ||
|- | |- | ||
| <code>□</code> || [[Box]] || Turn an array into a box | | <code>□</code> || [[Box]] || Turn an array into a box ([documentation https://www.uiua.org/docs/box]) | ||
|- | |- | ||
|} | |} | ||
==== Dyadic Array ==== | ==== Dyadic Array ==== | ||
Operate on two arrays | Operate on two arrays | ||
{| class="wikitable | {| class="wikitable" | ||
|+ Table of Monadic Array in Uiua | |+ Table of Monadic Array in Uiua | ||
! Glyph !! Name !! Definition | ! Glyph !! Name !! Definition |
Revision as of 13:14, 27 January 2024
Uiua is a stack-based array language designed by Kai Schmidt using glyphs inspired mainly by BQN.
Overview
Uiua uses concatenative evaluation (a context-free grammar) with a right-to-left ordering as in Polish notation. The language supports tacit programming using stack manipulation primitives, and all complex functions must be defined this way as there is no explicit function form that allows local variables. Functions have a fixed number of input and output values, meaning the overloading of ambivalent functions is removed. Because of this, Uiua often splits APL primitives into two functions. Its primitives use Unicode glyphs including many not found in other languages. To avoid the need for a keyboard layout containing these, each primitive can also be spelled using a name that consists of lowercase letters (user-defined names must have at least one uppercase letter). By default, the language formats source files when run to convert these names into the corresponding glyphs.
Like the SHARP APL family, arrays are flat with a homogeneous type; however, functions in Uiua are first-class values, and instead of boxes, niladic constant-valued functions are used to provide array nesting.
Uiua was featured on Array Cast in 2023.
Primitives
Function
In the web version of Uiua, we can type in the name of the function or a part of it and when run, the interpreter will format the name to Unicode Symbol, so that we don't need use of non-ASCII keyboards. All table below are base on the Uiua 0.8.0 Version.
Stack
Work with the stack
Glyph | Name | Type | Definition |
---|---|---|---|
. |
Duplicate | Monadic 2-output function | Duplicate the top value on the stack |
, |
Over | Dyadic 3-output function | Duplicate the second-to-top value to the top of the stack |
: |
Flip | Dyadic 2-output function | Swap the top two values on the stack |
◌(;) |
Pop | Monadic 0-output function | Discard the top stack value |
? |
Stack | Noadic 0-output function | Debug print all stack values without popping them |
⸮ |
Trace | Monadic function | Debug print the top value on the stack without popping it |
Constants
Push a constant value onto the stack
Glyph | Name | Definition |
---|---|---|
η |
Eta | The number of radians in a quarter circle |
π |
Pi | The ratio of a circle's circumference to its diameter |
τ |
Tau | The ratio of a circle's circumference to its radius |
∞ |
Infinity | The biggest number |
Monadic Pervasive
Operate on every element in an array
Glyph | Name | Definition |
---|---|---|
¬ |
Not | Logical not |
± |
Sign | Numerical sign (1, ¯1, or 0) |
¯ |
Negate | Negate a number |
⌵ |
Absolute value | Get the absolute value of a number |
√ |
Sqrt | Take the square root of a number |
○ |
Sine | Get the sine of a number |
⌊ |
Floor | Round to the nearest integer towards ¯∞
|
⌈ |
Ceiling | Round to the nearest integer towards ∞
|
⁅ |
Round | Round to the nearest integer |
Dyadic Pervasive
Operate on every pair of elements in two arrays (Note that True is 1 and False is 0)
Glyph | Name | Definition | Formats from: |
---|---|---|---|
= |
Equals | Compare for equality | = |
≠ |
Not equals | Compare for inequality | != |
< |
Less than | Compare for less than | < |
> |
Greater than | Compare for greater than | > |
≤ |
Less or equal | Compare for less than or equal | <= |
≥ |
Greater or equal | Compare for greater than or equal | >= |
+ |
Add | Add values | + |
- |
Subtract | Subtract values | - |
× |
Multiply | Multiply values | * |
÷ |
Divide | Divide values | % |
◿ |
Modulus | Modulo values | mod |
ⁿ |
Power | Raise a value to a power | pow |
ₙ |
Logarithm | Get the based logarithm of a number | log |
↧ |
Minimum/Logical And | Take the minimum of two arrays (Can use for logical AND.) | min |
↥ |
Maximum/Logical Or | Take the maximum of two arrays (Can use for logical OR.) | max |
∠ |
Atangent | Take the arctangent of two numbers | atan |
ℂ |
Complex | Make a complex number from imaginary and real parts | com |
Monadic Array
Operate on a single array
Glyph | Name | Definition |
---|---|---|
⧻ |
Length | Get the number of rows in an array |
△ |
Shape | Get the dimensions of an array |
⇡ |
Range | Make an array of all natural numbers less than a number |
⊢ |
First | Get the first row of an array |
⇌ |
Reverse | Reverse the rows of an array |
♭ |
Deshape | Make an array 1-dimensional |
¤ |
Fix | Add a length-1 axis to an array |
⋯ |
Bits | Encode an array as bits (LSB-first) |
⍉ |
Transpose | Rotate the shape of an array |
⍏ |
Rise | Get the indices into an array if it were sorted ascending |
⍖ |
Fall | Get the indices into an array if it were sorted descending |
⊚ |
Where | Get indices where array values are not equal to zero |
⊛ |
Classify | Assign a unique index to each unique element in an array |
◴ |
Deduplicate | Remove duplicate elements from an array |
◰ |
Unique | Get a mask of first occurrences of items in an array |
□ |
Box | Turn an array into a box ([documentation https://www.uiua.org/docs/box]) |
Dyadic Array
Operate on two arrays
Glyph | Name | Definition |
---|---|---|
≍ |
Match | Check if two arrays are exactly the same |
⊟ |
Couple | Combine two arrays as rows of a new array |
⊂ |
Join | Append two arrays end-to-end |
⊏ |
Select | Select multiple rows from an array |
⊡ |
Pick | Index a row or elements from an array |
↯ |
Reshape | Change the shape of an array |
☇ |
Rerank | Change the rank of an array's rows |
↙ |
Take | Take the first n elements of an array |
↘ |
Drop | Drop the first n elements of an array |
↻ |
Rotate | Rotate the elements of an array by n |
◫ |
Windows | The n-wise windows of an array |
▽ |
Keep | Discard or copy some rows of an array |
⌕ |
Find | Find the occurrence's of one array in another |
∊ |
Member | Check if each row of one array exists in another |
⊗ |
Indexof | Find the first index of each row of one array in another |
External links
- Uiua on the concatenative language wiki
- Doc for the Documentation
- Interpreter for the interpreter
- Basic to start learning Uiua
APL dialects [edit] | |
---|---|
Maintained | APL+Win ∙ APL2 ∙ APL64 ∙ APL\iv ∙ Aplette ∙ April ∙ Co-dfns ∙ Dyalog APL ∙ Dyalog APL Vision ∙ dzaima/APL ∙ GNU APL ∙ Kap ∙ NARS2000 ∙ Pometo ∙ TinyAPL |
Historical | A Programming Language ∙ A+ (A) ∙ APL# ∙ APL2C ∙ APL\360 ∙ APL/700 ∙ APL\1130 ∙ APL\3000 ∙ APL.68000 ∙ APL*PLUS ∙ APL.jl ∙ APL.SV ∙ APLX ∙ Extended Dyalog APL ∙ Iverson notation ∙ IVSYS/7090 ∙ NARS ∙ ngn/apl ∙ openAPL ∙ Operators and Functions ∙ PAT ∙ Rowan ∙ SAX ∙ SHARP APL ∙ Rationalized APL ∙ VisualAPL (APLNext) ∙ VS APL ∙ York APL |
Derivatives | AHPL ∙ BQN ∙ CoSy ∙ ELI ∙ Glee ∙ I ∙ Ivy ∙ J ∙ Jelly ∙ K (Goal, Klong, Q) ∙ KamilaLisp ∙ Lang5 ∙ Lil ∙ Nial ∙ RAD ∙ Uiua |
Overviews | Comparison of APL dialects ∙ Timeline of array languages ∙ Timeline of influential array languages ∙ Family tree of array languages |