Uiua: Difference between revisions

Jump to navigation Jump to search
2,692 bytes added ,  28 January
no edit summary
No edit summary
No edit summary
Line 170: Line 170:
| <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 ([https://www.uiua.org/docs/box documentation])
| <code>□</code> || [[Box]] || Turn an array into a box
This is Uiua's primary way to create nested or mixed-type arrays.
Normally, arrays can only be created if their rows have the same shape and type.
⬚ fill can help you with the shape part, but it is not always wanted, and it can't help with the type part.
You can go to ([https://www.uiua.org/docs/box To See more information about the <code>□ box</code> function])
|-
|-
|}
|}
Line 216: Line 220:
! Glyph !! Name !! Type !! Definition
! Glyph !! Name !! Type !! Definition
|-
|-
| <code>∵</code> || [[Each]] || Monadic modifier || Apply a function to each element of an array or arrays. This is the element-wise version of <code>≡ rows.</code>
| <code>∵</code> || [[Each]] || Monadic modifier || Apply a function to each element of an array or arrays.
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. This is the row-wise version of <code>∵ each.</code>
| <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>
|-
|-
| <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>
| <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>
|-
|-
| <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> || <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 228: Line 236:
| <code>⍢</code> || [[Do]] || Dyadic modifier || Repeat a function while a condition holds
| <code>⍢</code> || [[Do]] || Dyadic modifier || Repeat a function while a condition holds
|}
|}
==== Aggregating Modifiers ====
Apply a function to aggregate an array
{| class="wikitable"
|+ Table of Aggregating Modifiers in Uiua
! Glyph !! Name !! Definition
|-
| <code>/</code> || [[Reduce]] || Apply a reducing function to an array.
For reducing with an initial value, see <code>∧ fold</code>
|-
| <code>∧</code> || [[Fold]] || Apply a function to aggregate arrays.
|-
| <code>\</code> || [[Scan]] || Reduce, but keep intermediate values
|-
| <code>⊕</code> || [[Group]] || Group elements of an array into buckets by index
Takes a function and two arrays.
The arrays must be the same <code>⧻ length.</code>
The first array must be rank <code>1</code> and contain integers.
Rows in the second array will be grouped into buckets by the indices in the first array.
Keys <code><0</code> will be omitted.
The function then processes each group in order. The result depends on what the function is.
If the function takes 0 or 1 arguments, then <code>⊕ group</code> behaves like <code>≡ rows.</code> This is called iterating <code>⊕ group.</code>
Expects as many arguments as its function takes.
The function must take at least 1 more argument than it returns outputs.
Arguments that are lower on the stack that will be used as accumulators.
Arguments that are higher on the stack will be iterated over.
The function will be repeatdely called with the rows of the iterated arrays followed by the accumulators.
On each iteration, the returned values will be used as the new accumulators.
|-
| <code>⊜</code> || [[Partition]] || Group sequential sections of an array
The most common use of <code>⊜ partition</code> is to split an array by a delimiter.


Takes a function and two arrays.
The arrays must be the same <code>⧻ length.</code>
The first array must be rank <code>1</code> and contain integers.
Consecutive rows in the second array that line up with groups of the same key in the first array will be grouped together.
Keys <code>≤0</code> will be omitted.
The function then processes each group in order. The result depends on what the function is.
If the function takes 0 or 1 arguments, then <code>⊜ partition</code> behaves like ≡ rows. This is called iterating ⊜ partition.
|}
==== Inversion Modifiers ====
Work with the inverses of functions
{| class="wikitable"
|+ Table of Iterating Modifiers in Uiua
! Glyph !! Name !! Definition
== 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
20

edits

Navigation menu