Destructuring
T ↦ P ≡ {K₁ V₁ K₂ V₂ …} ↦ {K₁ P₁ K₂ P₂ … CAPTURE?}syntax- Destructure table
T.
DestructureVᵢtoPᵢfor every equalKᵢ.
IfKᵢis:, interpret it as key"Pᵢ"literally.
IfKᵢstars with?, also matchnil.
IfCAPTUREis&as T*, setT*toT.
Gotcha:{}matches any table, not the empty table. T ↦ P ≡ [V₁ V₂ … Vₙ] ↦ [P₁ P₂ … Pₘ CAPTURE?]syntax- Destructure a sequence from table
T.
DestructureVᵢtoPᵢfor everyi ≤ m.
IfCAPTUREis&as T*, setT*toT.
IfCAPTUREis& T*, setT*to[Tₙ₊₁ … Tₘ].
Gotcha:[]matches any table, not the empty table. V ↦ P ≡ (values V₁ V₂ … Vₙ) ↦ (P₁ P₂ … Pₘ)syntax- Destructure multiple values.
DestructurePᵢtoVᵢfor everyi ≤ m.
Gotcha: Multiple values cannot be nested. X ↦ Ebase case syntax- If
Eis literal, checkX = E.
IfEis identifier, bindEtoX(†).
(†) If not documented otherwise, such as inmatch. X ↦ _convention- Ignore
E.
Also_Efor anyE.