Compare each item one by one in two arrays

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

Parents
  • 0
    Certified Lead Developer

     ...

    a!localVariables(
    
      local!dtmdata: { 9, 9, 33, 33 },
      local!databaseData: { 9, 33, 33, 33 },
      
      local!notAtIndex: a!forEach(
        items: local!dtmdata,
        expression: if(
          /* using index() here as it will allow the logic to run without breaking even if arrays are different lengths */
          index(local!databaseData, fv!index, null()) = fv!item,
          {},
          fv!index
        )
      ),
      
      local!notAtIndex
    )

Reply
  • 0
    Certified Lead Developer

     ...

    a!localVariables(
    
      local!dtmdata: { 9, 9, 33, 33 },
      local!databaseData: { 9, 33, 33, 33 },
      
      local!notAtIndex: a!forEach(
        items: local!dtmdata,
        expression: if(
          /* using index() here as it will allow the logic to run without breaking even if arrays are different lengths */
          index(local!databaseData, fv!index, null()) = fv!item,
          {},
          fv!index
        )
      ),
      
      local!notAtIndex
    )

Children
No Data