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?

Y1=:0&{::
Y2=:1&{::
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."

http://code.jsoftware.com/wiki/Vocabulary/idot#dyadic
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm

Reply via email to