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 Also this answer here at math stack exchange https://math.stackexchange.com/questions/856153/the-j-progra...
The 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?
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 Also this answer here at math stack exchange https://math.stackexchange.com/questions/856153/the-j-progra...
The 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?
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 Also this answer here at math stack exchange https://math.stackexchange.com/questions/856153/the-j-progra...
The 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?
If 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
The 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?
If 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
The 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?
If 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
/ 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.
The 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?
If 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
> 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?
If 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
> 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?
If 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
/ 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
Ah so the explanation is pretty much just “magic”.
/ 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
Ah so the explanation is pretty much just “magic”.
It'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.