Skip to content

Commit 29c87e3

Browse files
committed
join box lists in recur
1 parent cd60f92 commit 29c87e3

File tree

1 file changed

+12
-2
lines changed

1 file changed

+12
-2
lines changed

src/algorithm/recur.rs

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ pub fn recur(is_leaf: SigNode, children: SigNode, combine: SigNode, env: &mut Ui
7171
scalar_child,
7272
}) = stack.pop()
7373
{
74-
println!("value: {value:?}, parent: {parent:?}, child_nodes: {child_nodes:?}");
74+
// println!("value: {value:?}, parent: {parent:?}, child_nodes: {child_nodes:?}");
7575
if let Some(child_nodes) = child_nodes {
7676
env.push_all(
7777
(consts.iter())
@@ -80,6 +80,16 @@ pub fn recur(is_leaf: SigNode, children: SigNode, combine: SigNode, env: &mut Ui
8080
);
8181
let children_value = if scalar_child && child_nodes.len() == 1 {
8282
child_nodes.into_iter().next().unwrap()
83+
} else if child_nodes
84+
.iter()
85+
.all(|val| matches!(val, Value::Box(_)) && val.rank() <= 1)
86+
{
87+
let mut child_nodes = child_nodes.into_iter();
88+
let mut val = child_nodes.next().unwrap();
89+
for child in child_nodes {
90+
val = val.join(child, false, env)?;
91+
}
92+
val
8393
} else {
8494
Value::from_row_values(child_nodes, env)?
8595
};
@@ -135,7 +145,7 @@ pub fn recur(is_leaf: SigNode, children: SigNode, combine: SigNode, env: &mut Ui
135145
env.exec(children.clone())?;
136146
let children = env.pop("child nodes")?;
137147
let index = stack.len();
138-
println!("{value:?} has children {children:?}");
148+
// println!("{value:?} has children {children:?}");
139149
stack.push(RecNode {
140150
parent,
141151
value,

0 commit comments

Comments
 (0)