I often get tripped up with different trailing shapes when using i. with
char arrays. I must not be the only one[1]

Does this look like a suitable utility to deal with it or is there a more
common way?

idotfill =. (( ( (_,]) {. Y1@[) i. ((_,]) {. Y2@[) ) {:@$@Y2 >. {:@$@Y1) f.

idotfill (>'SF';'SY';'PK ');(>'SF';'SY')
0 1

compare with

NB. different trailing shape
(>'SF';'SY';'PK ') i. (>'SF';'SY')
3 3

NB. remove the trailing space on PK

(>'SF';'SY';'PK') i. (>'SF';'SY')
0 1

[1] - "y must match the entire row of x (including any trailing fill
letters) for (i.) to find it. Otherwise (i.) returns (#x) (signifying "not
found"), concealing your error."

For information about J forums see http://www.jsoftware.com/forums.htm

Reply via email to