diff options
| author | Marshall Lochbaum <mwlochbaum@gmail.com> | 2022-06-13 13:07:24 -0400 |
|---|---|---|
| committer | Marshall Lochbaum <mwlochbaum@gmail.com> | 2022-06-13 13:07:24 -0400 |
| commit | dcbb72306821e0856c32944a54ea93902ef2949f (patch) | |
| tree | ff2163ad907df0f64e49352936dc5c6c07c6903f /vm.bqn | |
| parent | b6bcf214e638fd36ef7d76c9f573a84e6e016482 (diff) | |
Implement high-rank array notation [] (including destructuring)
Diffstat (limited to 'vm.bqn')
| -rw-r--r-- | vm.bqn | 10 |
1 files changed, 10 insertions, 0 deletions
@@ -49,6 +49,15 @@ ref ← { SetN ⇐ {𝕨.SetN𝕩}_set_"←" SetU ⇐ {𝕨.SetU𝕩}_set_"↩" SetQ ⇐ ∨´ {𝕨.SetQ𝕩}_set_@ + # Create a merged reference array based on this one + Merge ⇐ {𝕊: + Split ← { + "[…]←: Value must have rank 1 or more" ! 1≤=𝕩 + <˘ 𝕩 + } + Get ⇐ > Get + SetN‿SetU‿SetQ ⇐ {𝕏⟜Split}¨ SetN‿SetU‿SetQ + } } # Alias, like ⇐vals in ⟨a‿b⇐vals⟩← # It behaves like ⟨a‿b⟩← except when destructuring a namespace (GetF) @@ -127,6 +136,7 @@ ops ← ((!∘"Unknown opcode")˙⊣´⊢)¨ ⊔˝ ⍉> ⟨ # Arrays 11‿{i←𝕏@ ⋄ {s𝕊e: s.Push ⌽s.Pop i } } 12‿{i←𝕏@ ⋄ {s𝕊e: s.Push ref.Array ⌽s.Pop i } } + 14‿( {s𝕊e: s.Push =◶{𝕩.Merge@}‿> ⊑s.Pop 1 }˙) # Application 16‿( {s𝕊e: s.Push { f‿x: F x } s.Pop 2 }˙) 17‿( {s𝕊e: s.Push { w‿f‿x: w F x } s.Pop 3 }˙) |
