[Jprogramming] substring matching between two arrays
Joe Bogner
joebogner at gmail.com
Tue Nov 13 00:00:20 UTC 2018
Thanks all. The solutions above were more complicated than I expected. I
had assumed I was missing something obvious. The obvious miss was to use /
... I was thinking I could do something with rank alone
For comparison it is combination of map and reduce in javascript
['Joe B','Joe Q','Bobby Z','Janet F'].map(function(x) { return
['Joe','Bob','Jane'].reduce(function(acc,y,idx) { return
x.indexOf(y)>=0?idx:acc },-1) })
[0, 0, 1, 2]
On Mon, Nov 12, 2018 at 6:17 PM 'Mike Day' via Programming <
programming at jsoftware.com> wrote:
> or this variant?
>> f(1 i.~"1+./@E.~&> /)s. NB. f & s obvious?
> 0 0 1 2
>> This lists the index of the first instance of a substring of each element
> of fullNames in the
> shortNames boxed list. It assumes it's there somewhere, but you can use
> the property
> that non-inclusion is shown by index = length or number of shortNames.
>> Any help,
>> Mike
>>> > On 12 Nov 2018, at 22:29, Brian Schott <schott.brian at gmail.com> wrote:
> >
> > Is this anything you can use?
> >
> > I.fullNames(((]))&: >"0/-:"1 ((#@]{.[))& >"0/) shortNames
> >
> >
> > --
> > (B=) <-----my sig
> > Brian Schott
> > ----------------------------------------------------------------------
> > For information about J forums see http://www.jsoftware.com/forums.htm
>> ----------------------------------------------------------------------
> For information about J forums see http://www.jsoftware.com/forums.htm
More information about the Programming
mailing list