Sometimes an operation will retun an array with a trailing singleton
dimension
This is easy to fix:
$ ,"2 i. 3 4 1
3 4
$ ,"2 i. 3 4 4 4 1
3 4 4 4
$ ,"2 i. 3 1
3
$ ,"2 i. 3
3
is there a smart way to lop off a leading singleton dimension?
Also easy:
$ {. i. 1 3 4
3 4
$ {. i. 1 3 4 4 4
3 4 4 4
$ {. i. 1 3
3
Be sure to use these only as directed. Examples of the pitfalls:
$ 3
$ (,"2) 3 NB. Added a dimension
1
$ ,"2 i. 3 4
12
$ ,"2 i. 3 4 5
3 20
$ i. 3
3
$ {. i. 3 NB. Removed a dimension & lost data
So, now that I've given you the bandaid, I'd like to teach you
preventative medicine. You should (nearly) always be able to predict
the ranks of the results produced by your code.
If you cannot, and you find you "need to remove a trailing axis", it's
better to investigate why that's so, and modify the code that produces
the trailing axis, rather than removing it ex post facto.
If you post a small working example of the code that's causing you
trouble, we'll probably be able to explain what's wrong, and help you
fix it.
-Dan
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm