June Kim wrote:
> Could anyone suggest easier way to do what addln does? (addln
> should add line numbers with the starting columns of actual text
> being the same for all lines
> addln=:[: ; (<"1@":@,[EMAIL PROTECTED]@# ([ ; ' ' ; ])&(":@>) ])@(<;.2)
Here's a slightly shorter verb that produces identical results:
adln1=: [: ;@(] ,L:0"_1~ 1 ":@i.@,~ #) <@,~&' ';.2
Here's a slightly shorter verb that merely satisfies the description:
adln2=: [: ;@(":@>@[EMAIL PROTECTED] ,L:0"_1 ]) <@,~&' ';.2
Here's a slightly shorter verb that produces a look-alike character matrix:
adln3=:[: (":@,[EMAIL PROTECTED]@#,. ' ',. ]) ];._2
Basically, you've got some complexity in changing basis (LF terminated
to boxed, and back), some in padding, some in ensuring the line labels
are equal width, etc. Beyond a certain point, the only way to simplify
is to eliminate some of that complexity.
--
Raul
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm