NB. I often want to convert a string entered with 0 : 0
NB. to an array. That may work better with a J design anyway.
stoa =: ] ;._2
NB. Your function can then use # to generate the
NB. line numbers
addlnm =: ([: ": ,[EMAIL PROTECTED]@#),.' ',. ]
NB. addln =: [EMAIL PROTECTED] gives your display
NB. Using TAB for parens in first location as in others posts
a =: 0 : 0
((
abc
defg
)
lmn
)
)
addlnm stoa a -. TAB
0 ((
1 abc
2 defg
3 )
4 lmn
5 )
----- Original Message -----
From: "June Kim" <[EMAIL PROTECTED]>
To: "Programming forum" <[email protected]>
Sent: Monday, December 18, 2006 6:25 AM
Subject: [Jprogramming] adding lineno
Whenever it comes to handling strings, I feel like stumbling a bit.
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)
t=: 0 : 0
abc
defghi
lkmno
weqs
zzzzzzzz
q
ooo
ppp
q
r
suyv
ododps
)
addln=:[: ; (<"1@":@,[EMAIL PROTECTED]@# ([ ; ' ' ; ])&(":@>) ])@(<;.2)
addln t
0 abc
1 defghi
2 lkmno
3 weqs
4 zzzzzzzz
5 q
6 ooo
7 ppp
8 q
9 r
10 suyv
11 ododps
Thanks in advance for the learning experience. :)
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm