Uiua: Difference between revisions

From APL Wiki
Jump to navigation Jump to search
No edit summary
No edit summary
Line 31: Line 31:
== Primitives ==
== Primitives ==
=== Function ===
=== 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.
==== Stack ====
==== Stack ====
Work with the stack
Work with the stack
Line 38: Line 39:
! Glyph !! Name !! Type !! Definition
! Glyph !! Name !! Type !! Definition
|-
|-
| <code>.</code> || Duplicate || Monadic 2-output function || Duplicate the top value on the stack
| <code>.</code> || [[Duplicate]] || Monadic 2-output function || Duplicate the top value on the stack
|-
|-
| <code>,</code> || Over || Dyadic 3-output function || Duplicate the second-to-top value to the top of the stack  
| <code>,</code> || [[Over]]|| Dyadic 3-output function || Duplicate the second-to-top value to the top of the stack  
|-
|-
| <code>:</code> || Flip || Dyadic 2-output function || Swap the top two values on the stack  
| <code>:</code> || [[Flip]] || Dyadic 2-output function || Swap the top two values on the stack  
|-
|-
| <code>◌(;)</code> || Pop ||Monadic 0-output function || Discard the top stack value
| <code>◌(;)</code> || [[Pop]] ||Monadic 0-output function || Discard the top stack value
|-
|-
| <code>?</code> || Stack || Noadic 0-output function || Debug print all stack values without popping them
| <code>?</code> || [[Stack]] || Noadic 0-output function || Debug print all stack values without popping them
|-
|-
| <code>⸮</code> || Trace || Monadic function || Debug print the top value on the stack without popping it
| <code>⸮</code> || [[Trace]] || Monadic function || Debug print the top value on the stack without popping it
|-
|-
|}
|}
Line 57: Line 58:
!Glyph !! Name !! Definition
!Glyph !! Name !! Definition
|-
|-
| <code>η</code> || Eta || The number of radians in a quarter circle
| <code>η</code> || [[Eta]] || The number of radians in a quarter circle
|-
|-
| <code>π</code> || Pi || The ratio of a circle's circumference to its diameter
| <code>π</code> || [[Pi]] || The ratio of a circle's circumference to its diameter
|-
|-
| <code>τ</code> || Tau || The ratio of a circle's circumference to its radius
| <code>τ</code> || [[Tau]] || The ratio of a circle's circumference to its radius
|-
|-
| <code>∞</code> || Infinity || The biggest number
| <code>∞</code> || [[Infinity]] || The biggest number
|}
|}
==== Monadic Pervasive ====
==== Monadic Pervasive ====
Line 71: Line 72:
! Glyph !! Name !! Definition
! Glyph !! Name !! Definition
|-
|-
| <code>¬</code> || Not || Logical not
| <code>¬</code> || [[Not]] || Logical not
|-
|-
| <code>±</code> || Sign || Numerical sign (1, ¯1, or 0)
| <code>±</code> || [[Sign]] || Numerical sign (1, ¯1, or 0)
|-
|-
| <code>¯</code> || Negate || Negate a number
| <code>¯</code> || [[Negate]] || Negate a number
|-
|-
| <code>⌵</code> || Absolute value || Get the absolute value of a number
| <code>⌵</code> || [[Absolute value]] || Get the absolute value of a number
|-
|-
| <code>√</code> || Sqrt || Take the square root of a number
| <code>√</code> || [[Sqrt]] || Take the square root of a number
|-
|-
| <code>○</code> || Sine || Get the sine of a number
| <code>○</code> || [[Sine]] || Get the sine of a number
|-
|-
| <code>⌊</code> || Floor || Round to the nearest integer towards <code>¯∞</code>
| <code>⌊</code> || [[Floor]] || Round to the nearest integer towards <code>¯∞</code>
|-
|-
| <code>⌈</code> || Ceiling || Round to the nearest integer towards <code>∞</code>
| <code>⌈</code> || [[Ceiling]] || Round to the nearest integer towards <code>∞</code>
|-
|-
| <code>⁅</code> || Round || Round to the nearest integer
| <code>⁅</code> || [[Round]] || Round to the nearest integer
|}
|}
==== Dyadic Pervasive ====
==== Dyadic Pervasive ====
Line 93: Line 94:
{| class="wikitable" style="margin:auto"
{| class="wikitable" style="margin:auto"
|+ Table of Monadic Pervasive in Uiua
|+ Table of Monadic Pervasive in Uiua
! Glyph !! Name !! Definition
! Glyph !! Name !! Definition !! Formats from:
|-
| <code>=</code> || [[Equals]] || Compare for equality || =
|-
| <code>≠</code> || [[Not equals]] || Compare for inequality || !=
|-
| <code><</code> || [[Less than]] || Compare for less than || <
|-
| <code>></code> || [[Greater than]] || Compare for greater than || >
|-
| <code>≤</code> || [[Less or equal]] || Compare for less than or equal || <=
|-
| <code>≥</code> || [[Greater or equal]] || Compare for greater than or equal || >=
|-
| <code>+<</code> || [[Add]] || Add values || +
|-
| <code>-</code> || [[Subtract]] || Subtract values || -
|-
| <code>×</code> || [[Multiply]] || Multiply values || *
|-
|-
| <code>=</code> || Equals || Compare for equality
| <code>
|}
|}
== External links ==
== External links ==

Revision as of 08:23, 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.

Stack

Work with the stack

Table of Stack function in Uiua
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

Table of Constants in Uiua
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

Table of Monadic Pervasive in Uiua
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)

Table of Monadic Pervasive in Uiua
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 *

External links

  • Uiua on the concatenative language wiki


APL dialects [edit]
Maintained APL+WinAPL2APL64APL\ivApletteAprilCo-dfnsDyalog APLDyalog APL Visiondzaima/APLGNU APLKapNARS2000PometoTinyAPL
Historical A Programming LanguageA+ (A) ∙ APL#APL2CAPL\360APL/700APL\1130APL\3000APL.68000APL*PLUSAPL.jlAPL.SVAPLXExtended Dyalog APLIverson notationIVSYS/7090NARSngn/aplopenAPLOperators and FunctionsPATRowanSAXSHARP APLRationalized APLVisualAPL (APLNext) ∙ VS APLYork APL
Derivatives AHPLBQNCoSyELIGleeIIvyJJellyK (Goal, Klong, Q) ∙ KamilaLispLang5LilNialRADUiua
Overviews Comparison of APL dialectsTimeline of array languagesTimeline of influential array languagesFamily tree of array languages