.. an excruciating attempt ..
f =. ('i.&1';'I.';'i:&1')&((128!:2)&.>)@ (;/)@ (=/)
g =. ({. <&> 1&{) +./@:*. (1&{ <&> {:)
]A=: 'CTGGTTGAT','GTAGTCATA','CATGTCTAA','TCGAAAGTT',:'CCGGAGAAG'
'TAG' g@f("1) A
NB. 0 1 0 1 0
On 2011-08-18 14:24, Ric Sherlock wrote:
> I saw the following thread on comp.lang.apl
> http://groups.google.com/group/comp.lang.apl/browse_thread/thread/89c585c9d1a7bd3a#
> and was trying to put together a (non-regex) J solution.
>
> Given the matrix:
> ]A=: 'CTGGTTGAT','GTAGTCATA','CATGTCTAA','TCGAAAGTT',:'CCGGAGAAG'
> CTGGTTGAT
> GTAGTCATA
> CATGTCTAA
> TCGAAAGTT
> CCGGAGAAG
>
> and the list 'TAG'
>
> Identify the rows of the matrix where the letters in the list occur in
> the order they appear in the list, but not necessarily adjacent to
> each other.
> So the result of a verb findinRows would be:
> A findinRows 'TAG'
> 0 1 0 1 0
>
> I have an answer below but am thinking there may be other approaches I'm
> missing
>
>
>
>
>
>
>
>
>
> Spoiler alert!!
>
>
>
>
>
>
> findinRows=: [: (1 e. ,@:(</))&>/ 2 (([: ($ #. ]) 4 $. [: $.</)&.>)/\
> [:<@I."1 ="_ 0
> ----------------------------------------------------------------------
> For information about J forums see http://www.jsoftware.com/forums.htm
>
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm