Skip to main content
shukurs0001
August 17, 2022
Question

How to find the max no from an array without using Max() ?

  • August 17, 2022
  • 2 replies
  • 0 views

Hi dear,

I have written code like in the picture, I just want to print the max no without using max function.

    2 replies

    August 17, 2022

    I tried , using todatasubset() function with using for each

    a!localVariables(
    local!data: { 10, 5, 25, 70, 12 },
    local!getdata: a!forEach(
    items: local!data,
    expression: { Maxnumber: fv!item }
    ),
    index(
    index(
    todatasubset(
    arrayToPage: local!getdata,
    pagingConfiguration: a!pagingInfo(
    startIndex: 1,
    batchSize: 100,
    sort: a!sortInfo(field: "Maxnumber", ascending: false)
    )
    ).data,
    "Maxnumber",
    1
    ),
    1,
    {}
    )
    )

    harshitb6843
    August 17, 2022

    I am just curious about why would you like to do it without the max() function? Because even tho there are multiple ways of doing it, but none of them will be as efficient as the max() function.