3 ms·
For starters, it can be argued that it remains closer to mathematical notation. Example: reduce(+, (j -> j*2^-j).(Float64.(1:n))) which can be written, bu
by forgotpwd16 5y ago
For starters, it can be argued that it remains closer to mathematical notation. Example:
reduce(+, (j -> j*2^-j).(Float64.(1:n)))
which can be written, but then kinda differs from APL approach of combining primitives
sum((j -> j*2^-j).(Float64.(1:n)))
compared to
+/j×2*-j←⍳n
Also the statement is more succinct, and that is better understood when you compare an APL one-liner with a multi-line code in the other two languages. I think this is its true strength.
- Bostonian 5y agoI think the Fortran equivalent using an implied do-loop is sum([(j*2**(-j),j=1,n)]) Modern Fortran is arguably an array programming language. It has array operations like Matlab, Python/Numpy, and R.
- Jtsummers 5y agoI find it weird that that's called "modern" Fortran when that came with Fortran 90. Then I remember that even in 2010 academics (perhaps one of the biggest producers of Fortran today) still seemed to be hung up on F77.
- Bostonian 5y agoYou are right that the Fortran community took a long time adopt standards later than F77. Gfortran handles Fortran 90 and 95 well now, and I think F2003 and F2008 (although I don't use too many features from those standards and cannot say for sure from personal experience). I don't remember how mature gfortran was in 2010. Maybe then g95 was more mature.
- kwertzzz 5y agoThe compactness of APL is indeed quite intriguing. One could also write your example in Julia by: sum(j -> j*2.0^(-j),1:n) sum(function,array) applies function to all elements of array before the summation (without need to allocate an intermediate array).