Skip to content

Commit

Permalink
make subscripted on work with function packs
Browse files Browse the repository at this point in the history
  • Loading branch information
kaikalii committed Jan 9, 2025
1 parent 3d13e06 commit 82da1e1
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 3 deletions.
13 changes: 10 additions & 3 deletions src/compile/modifier.rs
Original file line number Diff line number Diff line change
Expand Up @@ -114,11 +114,18 @@ impl Compiler {
Modifier::Primitive(Primitive::On) => {
let mut words = Vec::new();
for branch in pack.branches.iter().cloned() {
words.push(branch.span.clone().sp(Word::Modified(Box::new(Modified {
let mut word = Word::Modified(Box::new(Modified {
modifier: modifier.clone(),
operands: vec![branch.map(Word::Func)],
operands: vec![branch.clone().map(Word::Func)],
pack_expansion: true,
}))));
}));
if let Some(sub) = &subscript {
word = Word::Subscripted(Box::new(Subscripted {
n: sub.clone(),
word: branch.span.clone().sp(word),
}))
}
words.push(branch.span.sp(word));
}
self.words(words)
}
Expand Down
2 changes: 2 additions & 0 deletions tests/units.ua
Original file line number Diff line number Diff line change
Expand Up @@ -419,6 +419,8 @@ B ← |1 (⨬(+⊃(B-1|B-2)|1)<2.)
⍤⤙≍ [1 2 3 4] [⟜₂+ 1 2 4]
⍤⤙≍ [1 2 7] [⟜₂(++) 1 2 4]

⍤⤙≍ {1 2 {1 2 [1 2 3]}} {⟜₂({⊙⊙∘}|[⊙⊙∘]) 1 2 3}

# By
⍤⤙≍ [0 5] [⊸0] 5
⍤⤙≍ [8 5] [⊸+] 3 5
Expand Down

0 comments on commit 82da1e1

Please sign in to comment.