diff --git a/src/algorithm/loops.rs b/src/algorithm/loops.rs index 1f91fa340..16f7412d2 100644 --- a/src/algorithm/loops.rs +++ b/src/algorithm/loops.rs @@ -70,6 +70,7 @@ pub fn repeat(with_inverse: bool, env: &mut Uiua) -> UiuaResult { let FixedRowsData { mut rows, row_count, + is_empty, .. } = fixed_rows(Primitive::Repeat.format(), sig.outputs, args, env)?; @@ -122,6 +123,9 @@ pub fn repeat(with_inverse: bool, env: &mut Uiua) -> UiuaResult { // Collect output for output in outputs.into_iter().rev() { let mut new_value = Value::from_row_values(output, env)?; + if is_empty { + new_value.pop_row(); + } let mut new_shape = new_shape.clone(); new_shape.extend_from_slice(&new_value.shape()[1..]); *new_value.shape_mut() = new_shape; diff --git a/src/algorithm/mod.rs b/src/algorithm/mod.rs index ac3d2e241..6ab4ed725 100644 --- a/src/algorithm/mod.rs +++ b/src/algorithm/mod.rs @@ -504,6 +504,7 @@ pub fn switch( let FixedRowsData { mut rows, row_count, + is_empty, .. } = fixed_rows("switch", sig.outputs, args, env)?; // Collect functions @@ -572,6 +573,9 @@ pub fn switch( // Collect output for output in outputs.into_iter().rev() { let mut new_value = Value::from_row_values(output, env)?; + if is_empty { + new_value.pop_row(); + } let mut new_shape = new_shape.clone(); new_shape.extend_from_slice(&new_value.shape()[1..]); *new_value.shape_mut() = new_shape;