On Fri, Aug 19, 2011 at 8:48 AM, R.E. Boss <[email protected]> wrote:
> Shaws solution is superior in every respect, more elegant, faster and
> leaner.
>
> A=:'CTGGTTGAT','GTAGTCATA','CATGTCTAA','TCGAAAGTT',:'CCGGAGAAG'
> B=:'TAGT'
>
> ts' AA findinRows_ML BB'[AA=: 500 $,:A [BB=:500$B
> 1.7589716 4.0105395e8
>
> ts' AA findinRows_SH BB'
> 0.13684443 33720960
>
> 1.7589716 4.0105395e8 % 0.13684443 33720960
> 12.853805 11.893314
>
> AA (findinRows_ML (-: |:) findinRows_SH) BB
> 1
I like Shaw's approach.
However, the efficiency issue is data dependent:
findinRows_SH=: +./@((*. +./\.)/@|:@(=/))
findinRows_ML=: [: *@#@> [: ([ #~ (< {:))&.>/ <@I.@(=/~)
data=: 'ACGT' {~ 4 ?.@$~ ]
AA=: data 20 3e3
BB=: data 1e3
ts 'AA findinRows_SH BB'
2.54335 1.34548e8
ts 'AA findinRows_ML BB'
1.09949 2.34531e8
--
Raul
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm