Verb k is my version of f written in "Simple J" which uses trains and
rank but no other conjunction. The expected left argument is a string,
right argument a list of boxed strings.
k =: ( ([: +/ E.) > )"1 0
'bc' k 'a bc def';'ab cde f';'abc d ef' NB. Is 'bc' a substring?
1 0 1
' ' k 'ab';'abc';'abcd' NB. two spaces a substring?
0 0 0
On 11/11/2011 1:19 PM, Kip Murray wrote:
> Verb f below is an example of "Subtle J". Is there a "Simple J" way?
>
> I first saw verb f in a note from Linda Alvord.
>
> f=: 13 :'x&(+./@E.)&>y'
>
> 'bc' f 'a bc def';'ab cde f';'abc d ef'
> 1 0 1
>
> As you see, f tells which strings on the right contain the left string.
>
> Experienced J users know that f operates by first forming the verb
> x&(+./@E.)&> and then applying that verb to y . They also know "that
> verb" will be applied to each box in y independently of the others and
> the separate results assembled into the final answer.
>
> Is there a way to do it using mostly trains and rank? A "Simple J" way
> for less experienced users?
>
> You hear the plea of an ex college teacher who dealt with less
> experienced users!
>
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm