I am very new to J (learning it for fun) and I am trying to read data from keyboard. I have tried to make a tiny script which reads in a string and reverses it:
|.(1!:1 3)
When I run it, I get a rank error. (I’m using 1!:1 3 instead of defining a verb because codegolf…)
Is there a command that can check the rank of 1!:1 3?
That’s a common mistake with foreigns.
The definition for foreign
1!:1doesn’t help, because it really reads:And so replacing
ywith3should work, right? Well, not quite, because what you’re really giving as an argument in writing:is an array made of
1 3. Sort of like giving it:when you want:
For code golf purposes, use a right bracket: