Is the 'reverse for' loop implemented in stan language?

Working on Hilbert spage GPs it would have been useful to be able to use a reverse loop but AFAIK it is not yet implemented in Stan. Is this correct or I missed something?

If you mean something like for (n in N:1) and having it to backwards or forwards based on the value of N, that isn’t something we even have planned for the future. You can create a container of those values and loop over that:

for (n in reverse(linspace_int_array(N, 1, N))) {
  ... loops from N to N - 1 to N - 2, ..., down to 1
}

You can store the array as transformed data to avoid reconstructing it each iteration.

A more general seq function would be nice, but that’s not available as far as I know. I think we may also add something like Python’s enumerate to get the best of for and foreach.

Thanks @Bob_Carpenter . I definitely go with the reverse function!