Greetings folks! Lets say I have an array which has duplicates of some elements (This is intentional). How might I go about reporting which of those elements do occur more than once in the array?
Example: Lets say I have an array with the following strings as elements:
Then, in blueprint, I compare that array to the input [Cat], and desire an output of ‘True’ (or alternatively an integer of the # of occurrences would be fine too). Using the input of [Dog] should yield the output ‘False’ (or integer 1).
Anyone know how I could achieve this?
Well I came up with a solution that accomplishes this, but it’s messy. If anyone knows an easier way I’d love to hear it.
Arrays in this image:
-
[Potential Doorway List] Contains all of the elements I’m interested in searching, including duplicates
-
[Potential Doorways Checker] Starts out blank, then becomes a duplicate array of the previous one, except the element which is currently the focus of our loop has been removed.
-
[Positions for Door BP] the preceding branch should add any duplicate elements it finds to this array, as my final list of all duplicates found.
Can´t you achive the exact thing you are asking for by a simple counter?
If the counter is 1 then there are no duplicates. (false)
2 or more would imply duplicates. (true)
0 is of course not found in array. (error message?)
I guess you would want to reset counter to 0 at starting the function.
Thanks for your suggestion. I considered having an INT that would count upward as it found matches, but I couldn’t visualize what that network would look like. I just happened to figure out the other method first so I went with that.
I’ve never seen that CompareInt node before, so I’ll file that away for future use =) Thanks for your help.