In response to my tweet about the Fortran: Array Language video, wws73 replied

F[ortran] 95 took some things from [High Performance Fortran], but IMHO not enough. They should’ve also incorporated the parallel prefix/suffix and sort/grade functions.

The article High Performance Fortran Programming - Detailed Notes (1996) by A C Marshall says this:

Prefix and Suffix FunctionsBoth classes of functions are related, Prefix functions go from left to right along an array. The difference between PRODUCT_PREFIX and PRODUCT is that the latter returns a single value whereas the former returns an array result. This array contains the value obtained by multiplying the current element by all the elements to the left of it. In the case of a 2D (or more) example, the array is traversed in array element order.

Suffix functions are exactly the same except that the array is traversed from right to left (or for multi-dimensional arrays in reverse array element order).

Prefix functions scan left to right along an array. Each element of the result depends upon the preceding elements (in array element order).

and gives examples. Does anyone remember why they were not incorporated into Fortran? I don’t have a strong opinion that they should be, but maybe stdlib could add such functions for all the basic types?

Regarding sort and grade, Beginner’s Guide to HPF – High Performance Fortran (1998) by Erin M. Miller says

HPF provides four functions for performing multidimensional array sorts which include GRADE_DOWN,

GRADE_UP, SORT_DOWN and SORT_UP.

GRADE_DOWN and GRADE_UP both return permutations of indices that arrange the array

elements in descending or ascending order, respectively. They do not return a sorted array. For

example, if`A = [ 13 20 17 11 ]`

then`GRADE UP(A) = [ 4 1 3 2 ]`

.

The general form of these two functions is:

`GRADE_UP(array[, dim])`

, and

`GRADE_DOWN(array[, dim])`

where array is an array of any type, and dim is an optional integer scalar indicating the dimension

along which the sorting is to be done.

The SORT_DOWN and SORT_UP functions, on the other hand, do return the actual sorted array.

Thus, for A above, the call`SORT_UP(A)`

returns`[ 11 13 17 20 ]`

.

The general form of these two functions is:

`SORT_UP(array[, dim])`

, and

`SORT_DOWN(array[, dim])`

where array is, again, an array of any type, and dim is an optional integer scalar indicating the

dimension along which the sorting is to be done.

These also seem like candidates for stdlib, if not the language proper.