3 ms·
So theres numpy: > b = np.arange(12).reshape(3,4) > b.cumsum(axis=1) or, would you prefer the following: > b =. 3 4 $ i. 12 > +/\"0 1 b Yeah, no thanks .
by isoprophlex 6y ago
So theres numpy:
> b = np.arange(12).reshape(3,4)
> b.cumsum(axis=1)
or, would you prefer the following:
> b =. 3 4 $ i. 12
> +/\"0 1 b
Yeah, no thanks ...
- jhayward 6y agoWhy would you pick the most trivial example, rather than something that shows the high-level expressiveness of J et. al.?
- irishsultan 6y agoIt's one of the most advanced examples on the linked page, definitely not the "most trivial".
- jhayward 6y agoIf the limit of one's experience with arrays is summing a column or row of numbers, perhaps one is not the target audience for an array programming language. Summing along an index is about the most trivial application of array processing imaginable.
- svantana 6y agoHonest question: couldn't you get equally expressive using english language keywords instead of cryptic characters?
- rscho 6y agoThere's a library in J for doing exactly that. Few people use it.
- yiyus 6y agoNot at all. Try to write equations using English words instead of "cryptic characters" and think which is more expressive, eg: a) a*(b+c) = a*b + a*c b) equal(multiply(a, add(b, c)), add(multiply(a, b), multiply(a, c)))
- irishsultan 6y agoThat's a problem with the linked post then (for not giving good examples), not with the example picked by isoprophlex
- kwhitefoot 6y agoI'm not familiar with either J or NumPy. I have no idea what the first line does in either of these examples. And the fact that NumPy uses an English word, axis, as a named argument means nothing at all to me I think it is an exaggeration to say that the NumPy is any clearer to the uninitiated than the J. Once one has learnt J then surely it is as easy to read as the NumPy? The NumPy just looks easier because the syntax is more familiar.
- isoprophlex 6y agoFor one, the numpy versions use method calls with human readable names. I prefer ergonomics and having my colleagues grok what a line does: eg. 'reshape' calls will change the shape of your array. Bless you if you're in an environment where you can always pick the tools that work for you. But I'm never going to convince my (java, scala, python, R) adept colleagues that they need J in their life. Here lie my gripes with the linked article, it's just not such a good sales pitch.
- dTal 6y ago>I'm not familiar with either J or NumPy... I have no idea what the first line does In that case, you owe it to yourself as a programmer to go and get familiar with some APL-isms, for they are for numerical arrays what regexes are for strings and are rapidly becoming ubiquitous[0]. I wowed my boss once because I was able to mold an array into the shape we needed it in a few seconds... in Mathematica, a language I had never used before that moment, because I knew what to search the documentation for. It doesn't matter where you get it from, just pick a language with APL-isms - I recommend NumPy if you like popular stuff, and Q'Nial if you like esolangs - and work through Project Euler without writing any loops. It'll be fun! And of course, if you're unfamiliar with the core concepts, then naturally both syntaxes will look equally opaque. That doesn't mean they are though. Once you understand what they are trying to express, then you will be in a better position to judge. [0] In Julia: b = reshape(1:12,(3,4)) cumsum(b,dims=2) #Julia is 1-indexed
- jeffreyrogers 6y agoThat numpy example is only obvious to you because you known numpy. Do you remember learning numpy? I do, and it was definitely not obvious how things worked or what certain functions did.
- UncleEntity 6y ago> or, would you prefer the following: b←3 4⍴⍳12 +⌿b ⍝ maybe, don't know if numpy/J starts at 0 or 1 -- assuming 0 There's been a lot of APL related posts lately and I've been fascinated on how one would go about parsing it so...