digitalmars.D - From APL
- bearophile (37/40) Sep 20 2012 The paper touches only a small subset of what's needed to write
- Simen Kjaeraas (6/29) Sep 21 2012 See attached. Mayhaps I should post this as a pull request?
The paper touches only a small subset of what's needed to write modern program, it's mostly about array operations and related matters. It compares some parts of the old Fortran 88 with parts of the dead APL language. The author seems fond of APL, and several things written in the paper are unfair: "Fortran 88 Arrays - Paper Clips and Rubber Bands" (2001), by Robert Bernecky: http://www.snakeisland.com/fortran8.htm Some of the ideas of APL are widely used in modern functional languages. D contains array operations and Phobos contains some higher order operations similar to some APL verbs and adverbs. ------------------ Section 2.3 is about Scan operations, that are like reduce or fold, but keep all the intermediate results too: +\ of 3 1 2 4 is 3 4 6 10 Some lazy scans are present in the Haskell Prelude too (and in Mathematica) (the Prelude contains functions and constants that are loaded on default): http://zvon.org/other/haskell/Outputprelude/scanl_f.html I think scans are not present in Phobos. Maybe one or two are worth adding. ------------------ Section 2.5 suggests to generalize the dot product:If the + and * of the Fortran 77 DO loops for inner product are replaced by other functions, a whole family of interesting inner products appear,<Some examples of usage (in J language): Associative search *./..=y Inverted associative x+./..~:y Minima of residues for primes x<./..|y Transitive closure step on Booleans y+./..*.y Minima of maxima x<./..>.y Maybe a higher order function named "dot" (that takes two callables) is worth adding to Phobos. But I am not sure. ------------------ Section 2.6 reminds us that a transpose() is a commonly useful function. A transpose is handy to have in Phobos. Bye, bearophile
Sep 20 2012
On Thu, 20 Sep 2012 13:55:48 +0200, bearophile <bearophileHUGS lycos.com> wrote:Section 2.3 is about Scan operations, that are like reduce or fold, but keep all the intermediate results too: +\ of 3 1 2 4 is 3 4 6 10 Some lazy scans are present in the Haskell Prelude too (and in Mathematica) (the Prelude contains functions and constants that are loaded on default): http://zvon.org/other/haskell/Outputprelude/scanl_f.html I think scans are not present in Phobos. Maybe one or two are worth adding.See attached. Mayhaps I should post this as a pull request?------------------ Section 2.5 suggests to generalize the dot product:So that's basically mapReduce, right? We've got that, just not as succinct. -- SimenIf the + and * of the Fortran 77 DO loops for inner product are replaced by other functions, a whole family of interesting inner products appear,<Some examples of usage (in J language): Associative search *./..=y Inverted associative x+./..~:y Minima of residues for primes x<./..|y Transitive closure step on Booleans y+./..*.y Minima of maxima x<./..>.y Maybe a higher order function named "dot" (that takes two callables) is worth adding to Phobos. But I am not sure.
Sep 21 2012