return false

This commit is contained in:
TreetopFlyer 2021-05-29 12:28:46 -04:00
parent 0032f41b01
commit 9ec0f1b8d7

View File

@ -8,48 +8,50 @@
<body> <body>
<script> <script>
var count = 0;
let root = N.Create("root"); let root = N.Create("root");
var context = {};
let recurse = (node, depth) => let recurse = (node, depth) =>
{ {
// create a set of new nodes off of the input node // create a set of new nodes off of the input node
let c1 = N.Create(node.Meta+"-1"); let c1 = N.Create(node.Meta+"-c1");
let c2 = N.Create(node.Meta+"-2"); let c2 = N.Create(node.Meta+"-c2");
N.Connect(node, c1, "parent"); N.Connect(node, c1, "parent");
N.Connect(node, c2, "parent"); N.Connect(node, c2, "parent");
var iterator; var iterator;
if(depth < 2) if(depth < 1)
{ {
// loop over the new nodes and keep recursing N.Walk((child) =>
iterator = (child) =>
{ {
console.log(`subdividing ${child.Meta}`);
context = [child, depth+1];
recurse(child, depth+1); recurse(child, depth+1);
}; return false;
}
, node, "parent");
} }
else else
{ {
// walk up
iterator = (child) => N.Walk((child) =>
{ {
/* /*
issue: why does incrementing walk id cause an infinite loop issue: why does incrementing walk id cause an infinite loop
*/ */
N.ID.Walk++; N.ID.Walk++;
count++; console.log(`changing walk ID ${child.Meta}`);
if(count > 100) if(N.ID.Walk > 20)
{ {
console.log("big problems"); console.log("big problems");
throw new Error("holy crap"); throw new Error("holy crap");
} }
}; return false;
}
, node, "parent");
} }
N.Walk(iterator, node, "parent");
} }
N.ID.Walk++; N.ID.Walk++;
context = [root, 0];
recurse(root, 0); recurse(root, 0);
</script> </script>