Hi
I need to compare each item in two arrays
e.g.
local!dtmdata: {9, 9, 33, 33},local!databaseData: {9, 33, 33, 33}
i have tried:
a!localVariables(
local!dtmdata: { 9, 9, 33, 33 }, local!databaseData: { 9, 33, 33, 33 }, local!notAtIndex: a!forEach( items: local!dtmdata, expression: if( wherecontains(fv!item, local!databaseData
), wherecontains(fv!item, local!databaseData
), "false" ) ), local!notAtIndex )
But its not sufficient as I want compare the numbers at each index
So I need to compare the first item in array local!dtmdata with the first item in array local!databaseData and so on. If at any point they are different then I need to know the index of the difference
in the example above it would return index 2 as it is different
Thanks!!
Discussion posts and replies are publicly visible
Few ways to do this, but Stefan's solution is by far the most efficient. However I might utilize a!foreach() with checking the max() length of either array to ensure all scenarios will be covered, and allow for scalability (say you want to ignore null values in the future). If we can spare the extra ~1.5 ms:
a!localVariables( local!dtmdata: {9, 9, 33, 33}, local!databaseData: {9, 33, 33, 33}, a!forEach( items: 1+enumerate(max(count(local!dtmdata),count(local!databaseData))), expression: if( index(local!dtmdata,fv!index,null)=index(local!databaseData,fv!index,null), {}, fv!index ) ) )