Wiwa
Wiwa is a stack-based, array-oriented esolang inspired by Uiua and BQN.
It operates on a stack of arrays. Each array can only contain other arrays, meaning there are no values in Wiwa.
You can find the interpreter here
Operations
There are a total of 58 operations in Wiwa.
The code is read char-by-char. Comments can be specified by surrounding them in square brackets ([]
).
Constants
Using these constants will push it onto the stack
Symbol | Description |
---|---|
Ø |
An empty array |
₁ ₂ ₃ ₄ ₅ ₆ ₇ ₈ ₉ ⏨ |
An array of 1-10 empty subarrays |
Stack Operations
Operations with the stack
Symbol | Name | Description |
---|---|---|
∥ |
swap | Swap the two arrays on top of the stack |
• |
clone | Duplicate the array on top of the stack |
↥ |
over | Duplicate the array below the top of the stack |
\ |
drop | Delete array on top of the stack |
↶ |
inner | Go into the array on top of the stack (use the array as a new stack) |
↷ |
outer | Go out of the array |
⋯ |
new | Create an empty array and use it as the new stack (same as Ø↶ )
|
⇅ |
rotate | Reverses the stack |
⊥ |
bottom | Duplicates the element on the bottom of the stack to the top of the stack |
Multiple Array Operations
Operations on multiple arrays, usually two arrays on top of the stack
Symbol | Name | Description |
---|---|---|
∩ |
concatenate | Concatenate two arrays on top of the stack |
∪ |
unpack | Move all subarrays from the array on top of the stack onto the stack |
⊃ |
shrink | Make both arrays be the same length by removing the last elements from the array on top of the stack |
∺ |
interleave | Merge both arrays by alternating between the elements of the first array (bottom) and second (top) |
∈ |
move | Move the array on top of the stack onto the array below the top of the stack |
∋ |
take | Take the last element from the array on top of the stack to the stack |
⊄ |
exclude | Remove subarrays from the array below the top of the stack whose length occurs in the array on top of the stack |
⊂ |
intersect | Remove subarrays from the array below the top of the stack whose length does not occur in the array on top of the stack |
⧺ |
length | Creates a new array with the same length as the array on top of the stack |
⧻ |
depth | Creates a new array with the same length as the greatest level of nesting in the array on top of the stack |
× |
repeat | Repeats subarrays in the array below the top of the stack by the length of the array on top of the stack |
÷ |
split | Split the array on top of the stack into two halfs (the second half is smaller if the amount of elements is odd) |
Single Array Operations
Operations on a single array that is on top of the stack
Symbol | Name | Description |
---|---|---|
⩷ |
flatten | Flatten all sub-arrays in the array (same as □↶∪↷ , or Ø∥∈↶∪↷ )
|
⊝ |
deduplicate | Removes subarrays with duplicated length from the array |
□ |
nest | Nests the array in an empty array (same as Ø∥∈ )
|
⇆ |
reverse | Reverses the array (same as ↶⇅↷ )
|
↥ |
maximum | Move the longest subarray of the array to the last element |
↧ |
minimum | Move the smallest subarray of the array to the last element |
⊢ |
flip | Swap the first element of the array with the last element |
∧ |
ascending | Sort the subarrays by their length ascending |
∨ |
descending | Sort the subarrays by their length descending |
⚂ |
random | Sort the subarrays randomly |
¤ |
increment | Add one empty subarray to the array (same as ↶Ø↷ )
|
⌑ |
decrement | Remove the last subarray from the array (same as ↶\↷ )
|
⊠ |
double | Repeat the subarrays in the array the length of the array (same as •× )
|
Control Flow
The lambda is started with λ
and ended with .
.
The lambda can be executed using the operations from the table below.
Symbol | Name | Description |
---|---|---|
λ |
lambda | Start the lambda |
. |
end | End the lambda |
∶ |
both | Execute the lambda on both arrays on top of the stack |
∵ |
each | Execute the lambda on each sub-array of the array on top of the stack (starting from the first; same as ↶∷↷ )
|
∷ |
all | Execute the lambda on all arrays on the stack (starting from the bottom) |
∅ |
until | Execute the lambda until the array on top of the stack is empty |
≍ |
matches | Execute the lambda if both arrays on top of the stack have the same length (doesn't pop them) |
⊃ |
execute | Execute the lambda |
You can have only one lambda, and creating another will override the previously defined one, but you can execute it multiple times without needing to re-define it.
You can also define or execute lambdas inside of lambdas, and this won't override the lambda globally.
λ∈λ∋..⊃⊃
This will do ∈
(move) twice despite the new lambda being overwritten inside of the lambda, since the override affects only the inside of the lambda.
λ∈λ∋.⊃.⊃
This, however, will execute ∈
(move) and ∋
(take).
I/O
Symbol | Name | Description |
---|---|---|
↪ |
output | Output a line to stdout using the length of subarrays of the array as charcodes |
↩ |
input | Read a line from stdin and push an array with the length of subarrays being the charcodes |
⍤ |
write | Write a character to stdout with the charcode of the length of the array on top of the stack |
⍣ |
read | Read a character from stdin and push an array with the length of the charcode onto the stack |
‣ |
keypress | Same as ⍣ , but keeps executing the lambda until a character has been inputted
|
? |
dump | Output the current stack |
Examples
Hello, World!
⋯₈₉ו₇₄פ∩•₇∩••₃∩₈₄×↥⊥⏨₅∩∩∥•₃∩⏨⊠•₈∩∥↷↪
Truth Machine
⍣₈₆פλλ•□↪.∅.≍\□↪
Cat program
₁λ⍣⍤.∅