6 ms·
I learned J before NumPy and I'm glad I did, because it's much easier to see and learn the algorithms when they're short symbols. Compare np.sqrt(sum(np.s
by hoosieree 5y ago
I learned J before NumPy and I'm glad I did, because it's much easier to see and learn the algorithms when they're short symbols.
Compare
np.sqrt(sum(np.square(x)))
versus
%: +/ *: x
So if you can translate one of the array languages to NumPy, you can tap into the wealth of "idioms" collected over the years.
For example: J Phrases[0] (organized by category), BQNcrate[1] and APLcart[2] (searchable).
[0]: https://www.jsoftware.com/help/phrases/sums_means.htm https://www.jsoftware.com/help/phrases/sums_means.htm
[1]: https://mlochbaum.github.io/bqncrate https://mlochbaum.github.io/bqncrate
[2]: https://aplcart.info/ https://aplcart.info/
- johndough 5y agoI think a fairer comparison would be np.linalg.norm(x) or even norm(x) if you import numpy.linalg.norm as norm beforehand. This comes with the advantage that you can look up the function by name to know what it does instead of having to look up chains of symbols on several websites.
- RodgerTheGreat 5y agoIn practice, if you're reading a J expression which contains unfamiliar primitives, there's only one place you need to look: https://code.jsoftware.com/wiki/NuVoc https://code.jsoftware.com/wiki/NuVoc Idioms are composed from primitives, but many of them are shorter than a descriptive name would be, and since the set of primitives is small (compared to the standard library in most languages), it doesn't take that long to memorize most or all of the symbols.
- kzrdude 5y agoInteresting suggestion since %: +/ *: x Is impossible to read of course without learning the J language's main constructs. While the python function application is easier to guess from other languages.