Comparing the elements of two strings in Appian

Well, 

I want to compare the elements of two Arrays in Appian. I have the image in my mind, but i can't do it in Appian.

The example is like this:

We have 2 Arrays: 

  • Array1: {100,200,300,400,700}
  • Array2: {100, 100, 300, 500,700}

The return that I deserve is:

True,False,True,False, True

I think it can be do it with forEach and Ifs, but I cant do it.

Actually I have got this:

load(
local!Array1: {100,200,300},
local!Array2: {100,200,300},
a!forEach(
items: local!Array1
a!forEach(
items: local!Array2
expression: if (local!Array1 = local!Array2, true, false)
)
)
)

With this ERROR: Expression evaluation error: Syntax error. Details: Expression evaluation error at function a!forEach parameter 2 [line 17]: Missing right parenthesis in expression, found 'expression'

Thanks for your time.

  Discussion posts and replies are publicly visible

Parents
  • Hey - try this:

    a!localVariables(
      local!Array1: {100,200,300,400,700},
      local!Array2: {100, 100, 300, 500,700},
      a!forEach(
        items: fn!merge(local!Array1,local!Array2),
        expression: fv!item[1]=fv!item[2]
      )
    )

    The key to this is to use the merge() function which creates a list of lists (that is, it takes the first item in your first array and pairs it with the first item in your second array, and then the second with the second...and so forth)

Reply
  • Hey - try this:

    a!localVariables(
      local!Array1: {100,200,300,400,700},
      local!Array2: {100, 100, 300, 500,700},
      a!forEach(
        items: fn!merge(local!Array1,local!Array2),
        expression: fv!item[1]=fv!item[2]
      )
    )

    The key to this is to use the merge() function which creates a list of lists (that is, it takes the first item in your first array and pairs it with the first item in your second array, and then the second with the second...and so forth)

Children