Searching for an array in an array

55 views
Skip to first unread message

P. Andreas Schmidt, IVE

unread,
Jan 17, 2023, 10:51:27 AM1/17/23
to Automate
Hi there,

I am planning on making a geo-location collection, so that would be an array with arrays, kind a like
[[5.124, 50.132], [6.324, 49.123], [7.132, 52.1234]]
So, I obviously want to be able to check if an adress is new or already in the array. Since written adresses sometimes vary little or much but end up the same (so even levenstein isn't really a solution), I'd also like to (double) check with the geo codes. But unfortunately in this scenario neither IndexOf nor contains work, at least as I tried, namely

indexOf(geocodesarray, [long, lat]) 
contains(geocodesarray, [long, lat])

long and lat being variables assigned from the geo location block

Is that supposed to work, but I'm doing something wrong? 
I've also just tried saving those two variables as an array, and using that new variable in the indexOf/contains, but same result. Obvioulsy I'm using one that's already present in my data set, so it should be found. What surprised me more is, when I compare (=) those two arrays, the "found" one, with the one present in the dataset, it returns false. Now I remember someone posting an array (deep) comparison flow that talked about that... 

So my guess is, the only way to do this would be:
1) loop through the whole data set with a for each until it matches, having to compare the two values inside, not the whole arrays against each other...
2) using findAll, joining the dataset array to a string, and as a regex "{long}, {lat}"

The second option obviously works... I just hoped there would be a more "direct" option.
Like I said, perhaps I'm missing something, and there is another (better) solution - please let me know!

Many thanks in advance

Henrik "The Developer" Lindqvist

unread,
Jan 17, 2023, 12:45:04 PM1/17/23
to Automate
Neither arrays nor dictionaries work with indexOf() nor contains() due to = only compares them by reference, not value. This will likely change in the future, so they're compared by value instead, but it will break existing flows, so some compatibility options has to be implemented.
The best alternative is likely to convert the coordinate to text in a standardized format , e.g. using coordFormat function, so they can be using as dictionary keys as well.
Reply all
Reply to author
Forward
0 new messages