Uiua: Difference between revisions

Jump to navigation Jump to search
1,384 bytes removed ,  14 April
→‎Function with unique glyph: Cut Cross, since it's been removed
(→‎Function with unique glyph: Cut Cross, since it's been removed)
 
(4 intermediate revisions by the same user not shown)
Line 25: Line 25:
Uiua uses concatenative evaluation (a [[wikipedia:context-free grammar|context-free grammar]]) with a right-to-left ordering as in [[Wikipedia: Polish notation|Polish notation]]. The language supports [[tacit programming]] using stack manipulation [[primitive]]s, and all complex functions must be defined this way as there is no explicit function form that allows local variables. [[Function]]s have a fixed number of input and output values, meaning the overloading of [[ambivalent function]]s 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 [[typing glyphs]] necessitating 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.
Uiua uses concatenative evaluation (a [[wikipedia:context-free grammar|context-free grammar]]) with a right-to-left ordering as in [[Wikipedia: Polish notation|Polish notation]]. The language supports [[tacit programming]] using stack manipulation [[primitive]]s, and all complex functions must be defined this way as there is no explicit function form that allows local variables. [[Function]]s have a fixed number of input and output values, meaning the overloading of [[ambivalent function]]s 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 [[typing glyphs]] necessitating 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, Uiua supports only [[Array_model#Flat_array_theory|flat arrays]] with a homogeneous [[type]], and has a dedicated [[box]] type for [[Nested array|array nesting]]. However, arithmetic is [[pervasion|pervasive]] as in the nested array model. Arithmetic also follows [[leading axis agreement]], extended so that a length-1 axis is matched with an axis of any length by replicating along it (like the broadcasting system of [[wikipedia:Julia (programming language)|Julia]] and [[wikipedia:NumPy|NumPy]]). It supports character arithmetic as in [[BQN]], as well as other primitives characteristic of BQN such as [[structural Under]], [[Classify]], and a [[Transpose]] that rotates the axes of its argument by one.
Like the [[SHARP APL]] family, Uiua supports only [[Array_model#Flat_array_theory|flat arrays]] with a homogeneous [[type]], and has a dedicated [[box]] type for [[Nested array|array nesting]]. However, arithmetic is [[pervasion|pervasive]] as in the nested array model. Arithmetic also follows [[leading axis agreement]], extended so that a length-1 axis is matched with an axis of any length by replicating along it (like the broadcasting system of [[wikipedia:Julia (programming language)|Julia]] and [[wikipedia:NumPy|NumPy]]). It supports [[character arithmetic]] as in [[BQN]], as well as other primitives characteristic of BQN such as [[structural Under]], [[Classify]], and a [[Transpose]] that rotates the axes of its argument by one.


== Primitives ==
== Primitives ==
Line 31: Line 31:
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.
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 based on Uiua version 0.8.0-1/28/2024.
Tables below are based on Uiua version 0.8.0, with since-removed primitives taken out.


<span style="color:black; background-color: yellow">Yellow background text </span> mean that the glyph is deprecated and will be removed in a future version
And 🧪 emoji mean that the glyph is experimental and may be changed or removed in the future.
==== Stack ====
==== Stack ====
Work with the stack
Work with the stack
Line 224: Line 221:
This is the element-wise version of <code>≡ rows.</code>
This is the element-wise version of <code>≡ rows.</code>
|-
|-
| <code>≡</code> || [[Rows]] || Monadic modifier ||Apply a function to each row of an array or arrays.
| <code>≡</code> || Rows || Monadic modifier ||Apply a function to each row of an array or arrays.
This is the row-wise version of <code>∵ each.</code>
This is the row-wise version of <code>∵ each.</code>
|-
|-
| <code>⊞</code> || [[Table]] || Monadic 2-argument modifier || Apply a function to each combination of rows of two arrays.
| <code>⊞</code> || Table || Monadic 2-argument modifier || Apply a function to each combination of rows of two arrays.
This is often what you want instead of <code>∵ each.</code>
This is often what you want instead of <code>∵ each.</code>
|-
| <code>⊠</code> || <span style="color:black; background-color: yellow">[[Cross]]</span> || Monadic 2-argument modifier || Apply a function to each combination of rows of arrays.
This was the row-wise version of <code>⊞ Table</code>
|-
|-
| <code>⍥</code> || [[Repeat]] || Monadic modifier || Repeat a function a number of times
| <code>⍥</code> || [[Repeat]] || Monadic modifier || Repeat a function a number of times
Line 246: Line 240:
For reducing with an initial value, see <code>∧ fold</code>
For reducing with an initial value, see <code>∧ fold</code>
|-
|-
| <code>∧</code> || [[Fold]] || Apply a function to aggregate arrays.
| <code>∧</code> || Fold || Apply a function to aggregate arrays.
|-
|-
| <code>\</code> || [[Scan]] || Reduce, but keep intermediate values
| <code>\</code> || [[Scan]] || Reduce, but keep intermediate values
|-
|-
| <code>⊕</code> || [[Group]] || Group elements of an array into buckets by index
| <code>⊕</code> || [[Group (BQN)|Group]] || Group elements of an array into buckets by index
Takes a function and two arrays.
Takes a function and two arrays.
The arrays must be the same <code>⧻ length.</code>
The arrays must be the same <code>⧻ length.</code>
Line 276: Line 270:
If the function takes 0 or 1 arguments, then <code>⊜ partition</code> behaves like <code>≡ rows</code>. This is called iterating <code>⊜ partition.</code>
If the function takes 0 or 1 arguments, then <code>⊜ partition</code> behaves like <code>≡ rows</code>. This is called iterating <code>⊜ partition.</code>
|}
|}
==== Inversion Modifiers ====
==== Inversion Modifiers ====
Work with the inverses of functions
Work with the inverses of functions
Line 284: Line 279:
| <code>°</code> || [[Un]] || Monadic modifier || Invert the behavior of a function
| <code>°</code> || [[Un]] || Monadic modifier || Invert the behavior of a function
Most functions are not invertible.
Most functions are not invertible.
|-
| <code>⌅</code> || <span style="color:black; background-color: yellow">🧪[[Rectify]]</span> || Monadic modifier ||🧪Set a function as its own inverse
|-
|-
| <code>⍜</code> || [[Under]] || Dyadic modifier || Apply a function under another
| <code>⍜</code> || [[Under]] || Dyadic modifier || Apply a function under another
Line 307: Line 300:
| <code>∘</code> || [[Identity]] || Monadic function || Do nothing with one value
| <code>∘</code> || [[Identity]] || Monadic function || Do nothing with one value
|-
|-
| <code>⋅</code> || [[Gap]] || Monadic modifier || Discard the top stack value then call a function
| <code>⋅</code> || Gap || Monadic modifier || Discard the top stack value then call a function
|-
|-
| <code>⊙</code> || [[Dip]] || Monadic modifier || Temporarily pop the top value off the stack and call a function
| <code>⊙</code> || Dip || Monadic modifier || Temporarily pop the top value off the stack and call a function
|-
|-
| <code>∩</code> || [[Both]] || Monadic 2-argument modifier || Call a function on two sets of values
| <code>∩</code> || Both || Monadic 2-argument modifier || Call a function on two sets of values
For monadic functions, <code>∩ both</code> calls its function on each of the top 2 values on the stack.
For monadic functions, <code>∩ both</code> calls its function on each of the top 2 values on the stack.
|-
|-
Line 317: Line 310:
<code>⊃ fork</code> is one of the most important functions for working with the stack.
<code>⊃ fork</code> is one of the most important functions for working with the stack.
|-
|-
| <code>⪾</code> || <span style="color:black; background-color: yellow">🧪[[Cascade]] || Dyadic modifier || 🧪Call one function after another, reusing some values
| <code>⊓</code> || Bracket || Dyadic modifier || Call two functions on two distinct sets of values
<code>⪾ cascade</code>'s second function is called, then its first argument(s) are reused, along with its output, as arguments to the first function.
|}
|-
| <code>⊓</code> || [[Bracket]] || Dyadic modifier || Call two functions on two distinct sets of values
|-
| <code>⋔</code> || 🧪[[All]] || Dyadic modifier || 🧪Call a function on many distinct sets of values
For just 2 sets of values, <code>∩ both</code> is often simpler.


The second function will be called, then the first function will be called on groups of values.
To do something similar to ∩ both on more than 2 sets of values, you can use <code>⊙ dip</code> and <code>∘</code> identity to select values.
|}
== External links ==
== External links ==
* [https://concatenative.org/wiki/view/Uiua Uiua] on the concatenative language wiki
* [https://concatenative.org/wiki/view/Uiua Uiua] on the concatenative language wiki

Navigation menu