Skip to content

Commit 113ad19

Browse files
committed
small dyadic level cleanup
1 parent 2aea802 commit 113ad19

File tree

1 file changed

+7
-7
lines changed

1 file changed

+7
-7
lines changed

src/algorithm/zip.rs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -570,6 +570,8 @@ fn dyadic_level(
570570
mut yn: usize,
571571
env: &mut Uiua,
572572
) -> UiuaResult {
573+
xn = xn.min(xs.rank());
574+
yn = yn.min(ys.rank());
573575
let xs_prefix = &xs.shape()[..xn];
574576
let ys_prefix = &ys.shape()[..yn];
575577
if !xs_prefix.iter().zip(ys_prefix).all(|(a, b)| a == b) {
@@ -584,11 +586,9 @@ fn dyadic_level(
584586
FormatShape(ys_prefix)
585587
)));
586588
}
587-
xn = xn.min(xs.rank());
588-
yn = yn.min(ys.rank());
589589
let xs_row_shape = Shape::from(&xs.shape()[xn..]);
590590
let ys_row_shape = Shape::from(&ys.shape()[yn..]);
591-
let mut new_rows = Value::builder(1);
591+
let mut new_rows = Vec::new();
592592
if xn == yn {
593593
for (x, y) in xs
594594
.row_shaped_slices(xs_row_shape)
@@ -598,9 +598,9 @@ fn dyadic_level(
598598
env.push(x);
599599
env.call_error_on_break(f.clone(), "break is not allowed in level")?;
600600
let row = env.pop("level's function result")?;
601-
new_rows.add_row(row, env)?;
601+
new_rows.push(row);
602602
}
603-
let mut new_value = new_rows.finish();
603+
let mut new_value = Value::from_row_values(new_rows, env)?;
604604
let mut new_shape = Shape::from_iter(if xs.shape().len() > ys.shape().len() {
605605
xs.shape()[..xn].iter().copied()
606606
} else {
@@ -617,10 +617,10 @@ fn dyadic_level(
617617
env.push(x.clone());
618618
env.call_error_on_break(f.clone(), "break is not allowed in level")?;
619619
let row = env.pop("level's function result")?;
620-
new_rows.add_row(row, env)?;
620+
new_rows.push(row);
621621
}
622622
}
623-
let mut new_value = new_rows.finish();
623+
let mut new_value = Value::from_row_values(new_rows, env)?;
624624
let mut new_shape =
625625
Shape::from_iter(xs.shape()[..xn].iter().chain(&ys.shape()[..yn]).copied());
626626
new_shape.extend_from_slice(&new_value.shape()[1..]);

0 commit comments

Comments
 (0)