Here's a nice tacit form, using recursion.
findinRows_2 =: (([}.~(i.{.))$:}.@])`(''-:])@.(0=*&#)"1
ts 'AA findinRows_2 BB'
0.0232118 19584
ts 'AA findinRows_EX BB'
0.0610122 11776
Marshall
On Fri, Aug 19, 2011 at 5:55 PM, Don Guinn <[email protected]> wrote:
> Haven't figured out how to make findinRows_EX tacit yet, but good if
> performance and simplicity are desired.
>
> A=:'CTGGTTGAT','GTAGTCATA','CATGTCTAA','TCGAAAGTT',:'CCGGAGAAG'
> B=:'TAGT'
>
> ts' AA findinRows_ML BB'[AA=: 500 $,:A [BB=:500$B
> 4.48007 2.08916e8
>
> ts' AA findinRows_SH BB'
> 0.567838 3.37196e7
>
> AA (findinRows_ML (-: |:) findinRows_SH) BB
> 1
>
>
> findinRows_EX=:(4 : 0)"1
> while. #x do.
> if. ''-:y do. 1 return. end.
> x=.x}.~x i.{.y
> y=.}.y
> end.
> 0
> )
>
> ts' AA findinRows_EX BB'
> 0.0826731 9472
> AA (findinRows_EX (-: |:) findinRows_SH) BB
> 1
> ----------------------------------------------------------------------
> For information about J forums see http://www.jsoftware.com/forums.htm
>
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm