Select to view content in your preferred language

Arcade numeric array

689
2
10-29-2022 05:02 PM
RobA
by
New Contributor

Hi there, 

I'm looking to create a numerical array in Arcade to be used for numerical calculations later in my function. 

I have an upper threshold for example : 

var threshold = 4

I simply want to create a numerical array starting from 0 and looping through to 4 to produce:

[0,1,2,3,4] saved as an accessible numerical array. 

This is a simple enough concept in R (Seq function) or Python (range function), but I'm scratching my head as to how to do this simple task using Arcade.  

Any help would be greatly appreciated. 

0 Kudos
2 Replies
jcarlson
MVP Esteemed Contributor

There's nothing built-in that does this, but you could easily create your own function:

function sequence(threshold){
    var out_arr = []
    for (var n=0; n <= threshold; n++){
        Push(out_arr, n)
    }
    return out_arr
}

jcarlson_0-1667185491884.png

- Josh Carlson
Kendall County GIS
RobA
by
New Contributor

That's perfect thanks Josh  😄

0 Kudos