Skip to content

Commit

Permalink
fix a crash in >dyadic each
Browse files Browse the repository at this point in the history
  • Loading branch information
kaikalii committed Jan 30, 2025
1 parent 29b0545 commit a7c1acf
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/algorithm/zip.rs
Original file line number Diff line number Diff line change
Expand Up @@ -519,7 +519,7 @@ fn eachn(f: SigNode, mut args: Vec<Value>, env: &mut Uiua) -> UiuaResult {
let mut arg_elems: Vec<_> = args
.into_iter()
.map(|val| {
let repetitions = elem_count / val.element_count();
let repetitions = elem_count / val.element_count().max(1);
val.into_elements()
.flat_map(move |elem| repeat(elem).take(repetitions))
})
Expand Down
2 changes: 2 additions & 0 deletions tests/loops.ua
Original file line number Diff line number Diff line change
Expand Up @@ -176,6 +176,8 @@ A ← ↯2_3_4⇡24
⍤⤙≍ ⬚0∵(++) [1] [2 3 4] [5 6] ⬚0(++) [1] [2 3 4] [5 6]
⍤⤙≍ [[1_2_8 1_3_8 1_4_8] [1_5_9 1_6_9 1_7_9]] ∵[⊙⊙∘] 1 [2_3_4 5_6_7] 8_9
⍤⤙≍ [[1_3 1_4] [2_3 2_4]] ∵⊂ [1 2] [[3 4]]
⍤⤙≍ [] ∵⋅⋅⋅1 [] [] []
⍤⤙≍ °△0_2 ∵⋅⋅⋅1 [] [] °△0_2

# Rows pervasive on scalars
⍤⤙≍ ¯5 ≡¯ 5
Expand Down

0 comments on commit a7c1acf

Please sign in to comment.