Hi!
If I have an array like this:
{0,1,2,2,7,9,9,9,33}
…How can I remove all the same values to end up with:
(0,1,2,7,9,33)
?
-Olivier
geo = hou.pwd().geometry() my_list = geo.intListAttribValue('my_list') # Get the detail attribute no_duplicates = list(set(my_list)) # Remove duplicates geo.setGlobalAttribValue('my_list', no_duplicates) # Store the new values
//i[]@List = {4,5,8,8,2,3,0,1};
//i[]@List = {4,4,8,8,2,3,8,4,8};
i[]@List = {1,8,8,2,7,3,8,4,8,6,7,1,1};
int Count, Count_A;
for(Count = 0; Count < len(i[]@List); Count++)
{
for(Count_A = 0; Count_A < len(i[]@List); Count_A++)
{
if( (i[]@List[Count] == i[]@List[Count_A]) && (Count != Count_A) )
{
removeindex(i@List, Count_A);
}
}
}int[] Remove_Duplicate_Array_Items(int Imported_Array[])
{
int List[];
int Count, Count_A;
List = Imported_Array;
for(Count = 0; Count < len(List); Count++)
{
for(Count_A = 0; Count_A < len(List); Count_A++)
{
if( (List[Count] == List[Count_A]) && (Count != Count_A) )
{
removeindex(List, Count_A);
}
}
}
return List;
}
#include <Remove_Duplicate_Array_Items.h>
#include <Remove_Duplicate_Array_Items.h>
//i[]@List = {4,5,8,8,2,3,0,1};
//i[]@List = {4,4,8,8,2,3,8,4,8};
i[]@List = {1,8,8,2,7,3,8,4,8,6,7,1,1};
i[]@List = Remove_Duplicate_Array_Items(i[]@List);
#include <Remove_Duplicate_Array_Items.h>
#include <Another_One_Of_My_Functions.h>
#include <One_Thousand_Line_Function.h>
//Happy coding here;
f[]@myarray = {1,1,1,2,2,3,4,5,5,5,6,7,7,7,8,8,9}; float current; float next; for(int i = len(@myarray); i > -1; i--) { current = @myarray[i]; next = @myarray[i-1]; if(current == next) { removeindex(@myarray, i); } }
evrstudio
you can also do this way:
int origLs = {1,1,1,2,2,3,4,5,5,5,6,7,7,7,8,8,9};
int setOrigLs = array();
foreach(int orig; origLs)
{
if (find(setOrigLs, orig) < 0)
append(setOrigLs, orig);
}
origLs = setOrigLs;
int origLs[] = {1,1,1,2,2,3,4,5,5,5,6,7,7,7,8,8,9}; int setOrigLs[]; foreach(int orig; origLs){ if (find(setOrigLs, orig) < 0) append(setOrigLs, orig); } origLs = setOrigLs;
OdFotan
Thank you.int origLs[] = {1,1,1,2,2,3,4,5,5,5,6,7,7,7,8,8,9}; int setOrigLs[]; foreach(int orig; origLs){ if (find(setOrigLs, orig) < 0) append(setOrigLs, orig); } origLs = setOrigLs;
TantoCool, thank you!
Yes, that's exactly what's happening.