Hi all,
I have a list where I would like to extract first items from every branch but if first item is same as item extracted before then extract next item. Please help.
duplicates.gh (10.1 KB)Hi all,
I have a list where I would like to extract first items from every branch but if first item is same as item extracted before then extract next item. Please help.
duplicates.gh (10.1 KB)It’s not an easy thing to do in grasshopper, maybe using C# or Python makes it easier.
private void RunScript(DataTree<int> x, ref object A)
{
List<int> nums = new List<int>();
foreach(List<int> branch in x.Branches)
foreach(int i in branch)
if(!nums.Contains(i))
{
nums.Add(i);
break;
}
A = nums;
}
Awesome work. You are from Utopia (advance civilization)
fyi: python version looks like this:
a=[]
for branch in x.Branches:
for i in branch:
if not i in a:
a.append(i)
break
Thank you very much for your algorithms. Is it possible to make this loop in clean manner without hoopsnake. So either in c# or python/ Kindly see the gh file
here same method as above… Keep adding next number in list where duplicates from other branch is not considered.
Thank you I really appreciate your work. But I need the numbers to add up in same branch and those numbers should not be repetitive like I have values with panels at end.
Thank you for the definition. But I am doing it more than once. Once first items of each branch is extracted, the loop starts with extracting the next item from each branch and continues until all numbers are extracted from list. All by not repeating same numbers.