The following came up during a short discussion on @milancurcic 's blog.
https://medium.com/modern-fortran/map-filter-reduce-in-fortran-2018-e40b93668ed9
I thought it will be a good starting point for me on this discourse.
Elemental feature is seen as a drop in replacement of map functions. However, I see, coming from some lisp background, a major difference between the two while dealing with multidimensional arrays. While Fortran indiscriminately applies same scalar function to all elements, map traditionally works on one dimension at a time.
Thus, defined a function: f(x) = 2x, both f([x1,x2,x3]) and map(f,[x1,x2,x3]) give [2x1,2x2,2x3]. However, if the f is so defined that f(x) = [x,2x] then f([x1,x2,x3]) is meaningless, while map(f,[x1,x2,x3])
is still applicable and gives: [[x1,2x1],[x2,2x2],[x3,2x3]]. Interestingly, I find myself facing the second situation more often than first. There is even more generalization taking cue from some of the fortran intrinsics: map(f,array[,dim]). (I’m a big fan of SPREAD intrinsic, BTW.)