Ok, just seen you need boolean, so better to have ssm =: +./@E. Sorry for that, Mike
Please reply to [email protected]. Sent from my iPad > On 26 Oct 2018, at 09:15, 'Mike Day' via Programming > <[email protected]> wrote: > > RE Boss has just beaten me to it, but before I read his contribution, here's > a fairly > idiomatic tacit, might well be in stdlib under some name (?). > The definition is followed by doing "run selection" (crtl-E) in JQt on a copy > of your Examples, so your answers are also interpreted to show I'm not > cheating! > But I'm adding the odd NB. > ssm =: +/@E. > > NB. start of selection > > 2 3 ssm 1 3 4 2 3 5 6 > 1 > > 1 > 1 > > 2 3 ssm 1 3 4 2 1 5 6 > 0 > > 0 > 0 > > 2 40 6 ssm 52 6 34 6 2 4 2 40 6 78 55 > 1 > > 1 > 1 > 2 40 6 ssm 52 6 34 6 2 4 2 39 6 78 55 > 0 > 0 > 0 > 1 1 ssm 1 0 1 0 1 0 1 0 1 1 0 1 0 0 1 > 1 > 1 > 1 > 1 1 ssm 1 0 1 0 1 0 1 0 0 1 0 1 0 0 1 > 0 > 0 > 0 > 0 1 0 1 0 ssm 1 0 1 0 1 0 1 0 0 1 0 1 0 0 1 > 3 > 1 > 1 > > NB. end of selection > Now to see what Mr Boss has to say! > > Mike > >> On 26/10/2018 08:45, Skip Cave wrote: >> I need a sub-string matching verb 'ssm' that will return a boolean '1' if >> the left argument matches any portion of the right argument. >> >> Examples: >> >> 2 3 ssm 1 3 4 2 3 5 6 >> >> 1 >> >> 2 3 ssm 1 3 4 2 1 5 6 >> >> 0 >> >> 2 40 6 ssm 52 6 34 6 2 4 2 40 6 78 55 >> >> 1 >> 2 40 6 ssm 52 6 34 6 2 4 2 39 6 78 55 >> 0 >> 1 1 ssm 1 0 1 0 1 0 1 0 1 1 0 1 0 0 1 >> 1 >> 1 1 ssm 1 0 1 0 1 0 1 0 0 1 0 1 0 0 1 >> 0 >> 0 1 0 1 0 ssm 1 0 1 0 1 0 1 0 0 1 0 1 0 0 1 >> 1 > > > --- > This email has been checked for viruses by Avast antivirus software. > https://www.avast.com/antivirus > > ---------------------------------------------------------------------- > For information about J forums see http://www.jsoftware.com/forums.htm ---------------------------------------------------------------------- For information about J forums see http://www.jsoftware.com/forums.htm
