i have a couple of questions for the J experts ..
i refined my previous version in light of the Shaw solution ..
findInRows =. +./@ ((*. (1&(|.!.0))@(>./\.))/) @ (=/)
(my previous attempt..
findInRows =. +./@ (>./\@{. *. 1&{ *. >./\.@{:)@ (=/)
..only checked for three chars, and didn't do a recursive beam on the
result .. and wasn't recursive at all! (but i think i got an incoherent
idea of the principle)
)
my two questions are ..
1. that left shift (rather than rotate) .. isn't there a less voluble
way to do a left shift rather than '1|.' with '!.0' bolted to it?
2. is '+./' inherently better than '>./' for raising a '1' to a trail of
'1's? (eg. i note that '0 +. 2' == '0 >. 2' == '2') ? .. they appear to
be identical.
as a J novice, i'd appreciate a reply.
On 2011-08-19 17:55, R.E. Boss wrote:
> Cerovski pointed out findinRows_SH was wrong, I corrected it to
> findinRows_SB
>
> findinRows_SB=: +./@((*. 1 |.!.0 +./\.)/@|:@(=/))
>
> AA findinRows_ML BB
> 1 0 0 0 0 0 0 0 0 0
>
> AA findinRows_SB BB
> 1 0 0 0 0 0 0 0 0 0
>
>
> R.E. Boss
>
>
>> -----Oorspronkelijk bericht-----
>> Van: [email protected] [mailto:programming-
>> [email protected]] Namens Brian Schott
>> Verzonden: vrijdag 19 augustus 2011 18:44
>> Aan: Programming forum
>> Onderwerp: Re: [Jprogramming] Search for ordered letters within lines of
>> matrix
>>
>> I get different results for ML and SH when I trim the data sets a little
> for my
>> slower computer.
>>
>> AA=: data 10 3e2
>> BB=: data 1e2
>> findinRows_SH=: +./@((*. +./\.)/@|:@(=/))
>> findinRows_ML=: [: *@#@> [: ([ #~ (< {:))&.>/<@I.@(=/~)
>>
>> (AA findinRows_ML BB)-:(AA findinRows_SH BB)
>> 0
>> (AA findinRows_ML BB)
>> 1 0 0 0 0 0 0 0 0 0
>> (AA findinRows_SH BB)
>> 1 0 1 1 0 1 0 1 1 1
>>
>> On Fri, Aug 19, 2011 at 11:06 AM, Raul Miller<[email protected]>
> wrote:
>>>
>>> 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
>>>
>> ----------------------------------------------------------------------
>> For information about J forums see http://www.jsoftware.com/forums.htm
>
> ----------------------------------------------------------------------
> For information about J forums see http://www.jsoftware.com/forums.htm
>
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm