07-01-2024 12:00 PM
Built into LabVIEW is the Remove Duplicates From 1D Array.vim. I also have a set of Array VIMs posted over on VIPM.IO. It has a Remove 1D Array Duplicates. If it is not sorted than it uses Sets and will return the Array with Unique values, and the Indices that were removed. If the Array is sorted it will return the same values, but now will just loop through the array once. OpenG has a similar function but it predated Sets and uses uses the Search 1D Array primitive.
Unofficial Forum Rules and Guidelines
Get going with G! - LabVIEW Wiki.
17 Part Blog on Automotive CAN bus. - Hooovahh - LabVIEW Overlord
07-01-2024 01:04 PM
@Hooovahh wrote:
Built into LabVIEW is the Remove Duplicates From 1D Array.vim.
Removing duplicates is not the same as telling (via a simple Boolean output!) if all elements are unique or not. Of course we don't know the final reason of the OP for this. 😄
07-01-2024 01:10 PM
@altenbach wrote:
@Hooovahh wrote:
Built into LabVIEW is the Remove Duplicates From 1D Array.vim.
Removing duplicates is not the same as telling (via a simple Boolean output!) if all elements are unique or not. Of course we don't know the final reason of the OP for this. 😄
I mean yes you are of course correct. I should have said use the function I referenced, then if the indices of elements removed is empty, then you know there were no duplicates. I guess with the native VIM you can look at the array size, and see if they are the same. If so you know there were no duplicates.
Unofficial Forum Rules and Guidelines
Get going with G! - LabVIEW Wiki.
17 Part Blog on Automotive CAN bus. - Hooovahh - LabVIEW Overlord
07-01-2024 01:11 PM
@davy.k wrote:
Could be a relevant edge case, though checking floating point numbers for equality is code smell and usually a bad idea IMO. I assumed that we're just using floating point in these examples because it's the default.
Yes, equal comparisons are somewhat dangerous for DBL, but in this case we are detecting true binary duplicates and if none are found, all elements are unique (...but some might be very, very similar). :D.
To decide if this is acceptable, we need to know much more about the actual use case.