❔ Iteration over multiple objects at the same time
How do I iterate through several objects at the same time. Supposedly the objects have the same properties and I want to concat obj1.prop1 + obj2.prop1, obj1.prop2+obj2.prop2 etc etc
21 Replies
.Zip
list1.Zip(list2).Select(...)
should do roughly thatwhat if i have 100 lists
use a
for
loop
also, why do you have 100 lists 😄well its 100 objects, each is sorta like a data set
image them as replicates of an experiment
i want to stitch same properties from each object together
right. I'd personally do that by putting all your objects into an array, then use
Aggregate
on that array
Its fine thinker, you dont have to delete 😄aggregate, alright ill look into it
wheres my chatgpt...
check the docs
Enumerable.Aggregate Method (System.Linq)
Applies an accumulator function over a sequence. The specified seed value is used as the initial accumulator value, and the specified function is used to select the result value.
check the examples here
Essentially
the actual method definition is hard to read
ill take a look
this is correct, Thing() can be object or function, and this will save on total ops
?
what is "lists"
list of lists?
no its the list of things
your "data sets"
i have a list of x objects
or just x objects
you'll need them to be enumerable, so you need to stick them in an array or something
thats not a problem
example:
the top line just creates 100 randomized "datasets"
Was this issue resolved? If so, run
/close
- otherwise I will mark this as stale and this post will be archived until there is new activity.