To find the greatest number in the array without max function

conventional method to find the gratest number using for loop 

  Discussion posts and replies are publicly visible

Parents
  • 0
    Certified Senior Developer

    This might be helpful.

    a!localVariables(
      local!listOfNumber: { 67, 80, 100, 102, 150 },
      a!forEach(
        items: local!listOfNumber,
        expression: a!localVariables(
          local!item: fv!item,
          local!updatedList: remove(local!listOfNumber, fv!index),
          if(
            count(
              wherecontains(
                true,
                a!forEach(
                  items: local!updatedList,
                  expression: local!item > fv!item
                )
              )
            ) = count(local!updatedList),
            fv!item,
            {}
          )
        )
      )
    )

Reply
  • 0
    Certified Senior Developer

    This might be helpful.

    a!localVariables(
      local!listOfNumber: { 67, 80, 100, 102, 150 },
      a!forEach(
        items: local!listOfNumber,
        expression: a!localVariables(
          local!item: fv!item,
          local!updatedList: remove(local!listOfNumber, fv!index),
          if(
            count(
              wherecontains(
                true,
                a!forEach(
                  items: local!updatedList,
                  expression: local!item > fv!item
                )
              )
            ) = count(local!updatedList),
            fv!item,
            {}
          )
        )
      )
    )

Children
No Data