3 ms·
I wanted to learn more about "J" and this person, it is a nifty language Some people might enjoy this thread on "A look at the J language: the fine line betwee
by molticrystal 5y ago
I wanted to learn more about "J" and this person, it is a nifty language
Some people might enjoy this thread on "A look at the J language: the fine line between genius and insanity (2012)"
https://news.ycombinator.com/item?id=16393873 https://news.ycombinator.com/item?id=16393873
Also this answer here at math stack exchange
https://math.stackexchange.com/questions/856153/the-j-programming-language-is-it-useful-for-mathematics/1761055#1761055 https://math.stackexchange.com/questions/856153/the-j-progra...
- masklinn 5y agoThe SO answer is easy to follow right until the final operator “/“ where it just goes “magic”. That’s less than helpful as the rest is quite straightforward aside from the syntax. Its very short description of the two-arguments version make it sound like a fold, but that wouldn’t generalise to what looks like a cartesian product, would it?
- deleted 5y ago[deleted]
- vidarh 5y agoIf I understand it right "*/" results in a function that applies "*" between its arguments. "~" takes the function f(x) on its left and the argument y on its right and turns it into f(y, y). So the right side of the tilde evaluates to a range 1..10. I think the tilde then turns its left and right into "*/"(1..10, 1..10), resulting in 1..10 * 1..10
- masklinn 5y ago> I think the tilde then turns its left and right into "/"(1..10, 1..10), resulting in 1..10 1..10 That is the part which doesn’t make sense to me: `/ v` is `foldl1 () v`, how does that generalise to a cartesian product when applied to >1 sequences?
- icen 5y agoDyadic `x / y` is different to monadic `/ y`
- danparsonson 5y agoSomething akin to a map operation maybe?
- icen 5y ago/ does different things depending on the arity of the preceding function. 'f/ x' is 'insert' - i.e. reduce, so that '+/ 1+i.10' yields 55. 'x f/ y' is 'table', inserting 'f' between each pair to form a generalised multiplication table. The documentation for j is unsurprisingly terse, but it is complete and very helpful. https://code.jsoftware.com/wiki/Vocabulary/slash#dyadic https://code.jsoftware.com/wiki/Vocabulary/slash#dyadic
- masklinn 5y agoAh so the explanation is pretty much just “magic”.
- icen 5y agoIt's no more magical than anything else. It just turns out that j has an operator that does exactly what you want. Having such operators and functions is far from an uncommon experience in j.
- masklinn 5y agoMy problem with this is not “J has an operator that does exactly what you want” it’s “J has operators which do entirely different things depending on the arity”, you can’t intuit the behaviour of the binary / from the unary, they are for all intents and purposes unrelated. As a result, the original mathexchange answer introducing / by explaining its unary behaviour (despite that being used nowhere in the answer) is solely a source of confusion.
- icen 5y agoThe original description is misleading, yes. The distinguishing between arities is a consistent feature of all of these languages. I find fluency comes quickly to it. Edit: as for intuition between the two, this is sometimes not obvious, but I think it's a sensible generalisation from the monadic case to the dyadic. How else would you want to extend a fold to two arguments?