Re:Help us collect modern Python NumPy code solutions
by johndough on Monday March 28, 2022 @08:44AM
(#30829916)
I 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.
Re:Help us collect modern Python NumPy code solutions
by RodgerTheGreat on Monday March 28, 2022 @10:15AM
(#30830699)
In 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
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.
Re:Help us collect modern Python NumPy code solutions
by kzrdude on Monday March 28, 2022 @12:57PM
(#30832655)
Interesting 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.
Compare
versus 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 [1]: https://mlochbaum.github.io/bqncrate [2]: https://aplcart.info/