iTranslated by AI
Uiua Development Environment
Continued from the above.
Font
The officially recommended DejaVu Sans Mono font.
Since the charm of Uiua is halved if the glyphs aren't displayed beautifully, the font choice is considered important.
Download it from the link below. It includes various derivative fonts, but look for DejaVu Sans Mono and install it.
On macOS, you can just double-click the corresponding DejaVuSansMono.ttf file and install it.
VSCode Extension
This is provided officially.
After installing it, DejaVu Sans Mono was automatically specified in the default settings for Uiua, which saved some effort.
// Configure settings where the uiua language takes precedence.
"[uiua]": {
"editor.semanticHighlighting.enabled": true,
"editor.inlayHints.enabled": "on",
"editor.fontFamily": "DejaVu Sans Mono, monospace",
"editor.fontSize": 16
},
There are only a few items that can be configured in the extension itself.
Just the item to specify the location of the Uiua executable. If it's in your PATH, you don't need to configure anything specifically.
{
// Path to the Uiua executable used by the Uiua extension. When empty, the extension will try to find the Uiua executable in your PATH environment variable.
"uiua.executablePath": ""
}
Trying it out
Copy and paste a suitable sample from the official documentation: https://uiua.org/pad?src=⇌[⍥(%2B%2C%2C)10 1 0]
- State immediately after pasting
- After saving the file. The extension's formatter runs and it's converted into glyphs.
- Hovering the cursor over each glyph displays a description. In this case,
⍥.
- Execution
$ uiua run
[7 1 9 9 5]
- Code explanation:
⌊×10[⍥⚂5]- Evaluated from right to left.
-
[]creates an array. - Push
5onto the stack. -
⚂randomoperator: Generates a random number. Random numbers are between 0 and 1. -
⍥repeatoperator: Repeats the argument operator (in this case, random) for the number of times popped from the stack (in this case, 5). The result is pushed onto the stack. - Push
10onto the stack. -
×multiplyoperator: Multiplies. Uiua operators usually handle both scalar values and collections [1] appropriately. In this case, it multiplies 10 by each element of the array. -
⌊flooroperator: Rounds down the number. In this case as well, it acts on each element of the array. - Finally, what remains on the stack is "an array with five numbers obtained by multiplying random 0-1 values by 10 and rounding them down."
- To see the intermediate progress, I'll insert the
.duplicateoperator, which duplicates the top element of the stack and pushes it onto the stack, to try and copy and keep the intermediate state.
⌊×.10.[⍥⚂5]
$ uiua run
[0.143500830471 0.987054020347 0.583803611989 0.59630190826 0.069020688416] # Array with 5 random numbers
[1.435008304713 9.870540203471 5.83803611989 5.963019082604 0.690206884163] # Multiply each value by 10
[1 9 5 5 0] # Round down
Impressions
Some glyphs are intuitive, while others are less so.
The code appearance is fun.
Code becomes even shorter than S-expressions.
Continued ↓
-
In Uiua, arrays are the only existing collection type. ↩︎
Discussion