'TAG' (i.@>:@#@[ (-:~.)"1 [:(]`[@.(1=-~))/\."(1) #@[ ,.~ i."1) A
0 1 0 1 0


R.E. Boss


> -----Oorspronkelijk bericht-----
> Van: [email protected] [mailto:programming-
> [email protected]] Namens Ric Sherlock
> Verzonden: donderdag 18 augustus 2011 15:25
> Aan: Programming forum
> Onderwerp: [Jprogramming] Search for ordered letters within lines of
matrix
> 
> I saw the following thread on comp.lang.apl
> http://groups.google.com/group/comp.lang.apl/browse_thread/thread/89c
> 585c9d1a7bd3a#
> 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

Reply via email to