News for hackers. Stuff that matters.
Re:Help us collect modern Python NumPy code solutions by hoosieree on Monday March 28, 2022 @08:17AM (#30829668)
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 [1]: https://mlochbaum.github.io/bqncrate [2]: https://aplcart.info/

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.
Re:Help us collect modern Python NumPy code solutions by hoosieree on Monday March 28, 2022 @02:04PM (#30833557)
I know English, so I'll just guess at what those non-English people are saying. What could go wrong?
Re:Help us collect modern Python NumPy code solutions by kzrdude on Monday March 28, 2022 @02:36PM (#30833942)
I know spanish so I understand some french sentences. It's actually quite easy to see what I don't understand. It doesn't usually go wrong.