I might be misremembering, but doesn’t C# (maybe LINQ) have a zip function? I use this a lot for iterating over N same-length iterables in one terse for loop in Python.
var twoTrees = c0.AllData(true).Zip(c1.AllData(true), (firstGoo,secondGoo) => new { firstGoo, secondGoo } );
foreach (var goos in twoTrees) {
var goo = goos.firstGoo.Value; // Value cannot be accessed anymore as var goo is IGH_Goo here
}
But after zipping the GH_Curve is made as IGH_Goo, and I cannot access value anymore goos.firstGoo.Value
I was wondering if it is possible to use Enumerator:
var c0Enumerator = c0.GetEnumerator();
var c1Enumerator = c1.GetEnumerator();
while (c0Enumerator.MoveNext() && c1Enumerator.MoveNext()) {
Object curve0 = c0Enumerator.Current;
Object curve1 = c1Enumerator.Current;
}
Ah, in that case, maybe a normal indexed loop would probably actually be terser and more readable. For reference, in Python zip would be used like this:
for a, b, c in zip(listA, listB, listC):
# do stuff with a, b, and c
Sorry to be jumping back to this 2 years later, but does this solution work for datatrees?
I’m trying to loop through 2 datatrees simultaneously: for a, b in zip(treeA, treeB):
but getting this error: Runtime error (ArgumentTypeException): __getitem__() takes exactly 2 arguments (1 given)
Do you know what’s the problem?