Online Course - Advanced Expressions: Part 2

Certified Associate Developer

Hi, everyone.

I'm learning from "Online Course - Advanced Expressions: Part 2".
I have a question about "Exercise: Looping Functions (Online Course | Learning at Appian)".

Exercise: Looping Functions(Online Course | Learning at Appian)

The answer of "Scenario 4" is 1333 (1332 + initial value 1), but adding all the values of "local!sensor" gives 1361.
The last value of 29 in the third map seems to be ignored.

a!localVariables(
 
  local!sensor: 
  {
    a!map(data: {125,92,22,63,73,28,19}),
    a!map(data: {35,65,92,22,63,73,28}),
    a!map(data: {2,35,65,22,63,73,18,29}),
    a!map(data: {9,35,65,63,35,28,19})
  },
....

....
  reduce(fn!sum, 1, local!sensor.data)

  
 )

Is the answer 1333 correct?
Is this behavior by design?

Regards!

  Discussion posts and replies are publicly visible

Parents
  • 0
    Certified Lead Developer

    I see the same behaviour on my Appian 23.1. I changed the code a bit to highlight the problem.

    a!localVariables(
    
      local!sensor: {
        a!map(data: {125,92,22,63,73,28,19}),
        a!map(data: {35, 65,92,22,63,73,28}),
        a!map(data: {2,  35,65,22,63,73,18,29}),
        a!map(data: {9,  35,65,63,35,28,19})
      },
      
      local!sum1: sum(1, local!sensor[1].data),
      local!sum2: sum(local!sum1, local!sensor[2].data),
      local!sum3: sum(local!sum2, local!sensor[3].data),
      local!sum4: sum(local!sum3, local!sensor[4].data),
      a!map(
        reduceResult: reduce(fn!sum, 1, local!sensor.data),
        manualResult: local!sum4,
        sumOnly: sum(1, local!sensor.data)
      )
    )

    , do you have any ideas?

Reply
  • 0
    Certified Lead Developer

    I see the same behaviour on my Appian 23.1. I changed the code a bit to highlight the problem.

    a!localVariables(
    
      local!sensor: {
        a!map(data: {125,92,22,63,73,28,19}),
        a!map(data: {35, 65,92,22,63,73,28}),
        a!map(data: {2,  35,65,22,63,73,18,29}),
        a!map(data: {9,  35,65,63,35,28,19})
      },
      
      local!sum1: sum(1, local!sensor[1].data),
      local!sum2: sum(local!sum1, local!sensor[2].data),
      local!sum3: sum(local!sum2, local!sensor[3].data),
      local!sum4: sum(local!sum3, local!sensor[4].data),
      a!map(
        reduceResult: reduce(fn!sum, 1, local!sensor.data),
        manualResult: local!sum4,
        sumOnly: sum(1, local!sensor.data)
      )
    )

    , do you have any ideas?

Children