uiua-lang / uiua

A stack-based array programming language
https://www.uiua.org
MIT License
1.6k stars 116 forks source link

how to use modifier to create multiple functions? #148

Closed goyalyashpal closed 1 year ago

goyalyashpal commented 1 year ago

description

is this possible?

minimum working example

⊞= ⊓'⊂@0'⊂@1 "abac" "cbaa"

titles (or alternate ways to say this)

legend

⊂join, ↻rotate, ∩both, ⊓bracket, ⊙dip

kaikalii commented 1 year ago

In the ⊞= ⊓'⊂@0'⊂@1 "abac" "cbaa" example, you could do a ⊙∶ to get the values in the right order and a ∩⊂ to join them. For cases with more arguments, you'd need a with planet notation.

goyalyashpal commented 1 year ago

a ⊙∶ to get the values in the right order and a ∩⊂ to join them

[∶] ∩⊂ ⊙∶ @0 @1 "ab" "bc"
≅ ["1bc" "0ab"] # 1

:+1:

goyalyashpal commented 1 year ago

~self hiding as offtopic~


things i got stuck at:


  1. Getting arbitrary stack on array:
# All of these work same for unloading a 4 member stack onto an array
# Rest can be figured out the same way
Mov ← [∩(∶∶)]
Mov ← [∩(⊙∘)]
Mov ← [⊙⊙⊙∘]
  1. Getting a join combo
# Get a `join` combo
∩∩(|1 ⊂∶/⊔) ⍥(⍚2(|1 /⊔))2 ⊞⊂ "01" {"ab" "bc"}
⍤ ∶≅, ["1bc" "0bc" "1ab" "0ab"] [∩(∶∶)]
  1. Getting a rot combo
# Get a `rot` combo
∩∩(|1 ↻∶/⊔) ⍥(⍚2(|1 /⊔))2 ⊞⊂ [1 2] {"abc" "fgh"}
⍤ ∶≅, ["hfg" "ghf" "cab" "bca"] [∩(∶∶)]
  1. Converting an array of arrays into array of boxes (to be used by above "combo" functions

[∶]/□⊔ [1_2_3 4_5_6]
⍤ ∶≅, {1_2_3 4_5_6}
kaikalii commented 1 year ago

Sorry, what are you asking?