For that I think you would be better off using the original
implementation posted at wikipedia.

The approach I posted seems to have a problem with it and I'm not
certain if the issue is efficiency or a logical failure, but
efficiency seems plausible.

-- 
Raul

On Sat, Feb 2, 2013 at 2:57 PM, R.E. Boss <[email protected]> wrote:
> What about
>
>    'thisisatestthisisatest' lcs 'testing123testingtesting123testing' ?
>
>
> R.E Boss
>
>
>> -----Oorspronkelijk bericht-----
>> Van: [email protected] 
>> [mailto:[email protected]] Namens Raul Miller
>> Verzonden: vrijdag 1 februari 2013 21:40
>> Aan: [email protected]
>> Onderwerp: Re: [Jprogramming] inverse oblique
>>
>> And... here, I solved the wrong problem.
>>
>> I should have used something like:
>>
>> common=: 2 2 <@({.@;@{. ([ ~.@, ;@:}:@] , (,&.> ;@{:)) }.&.>)@,;.3^:_
>> ((;~@#)&.> i.@$)@(=/)
>>
>> lcs=: [ {~ 0 {"1 ,&$ #: 0 >@{.@(#~ (= >./)@:(#@>))@({:: ,) common
>>
>>    'thisisatest' lcs 'testing123testing'
>> tsitest
>>
>> --
>> Raul
>>
>> On Thu, Jan 31, 2013 at 4:41 PM, Raul Miller <[email protected]> wrote:
>> > Thanks, this is great.
>> >
>> > Based on this, added another J implementation of the longest common
>> > subsequence task from rosettacode:
>> > http://rosettacode.org/wiki/Longest_Common_Subsequence#J
>> >
>> > It's this code:
>> >
>> > accumulate=: [ >. [ + *
>> > rateSequence=: <@(accumulate/\.)
>> > rateSeqs=: $ $ rateSequence/. /:&; </.@i.@$
>> > commonLengths=: rateSeqs&.|.@(=/)
>> > maxLen=: >./@,
>> > longest=: = maxLen
>> > longLoc=:  (-@maxLen ; 1 + {.@I.@:(+./)@longest)@commonLengths
>> > lcs=: [: > [: {.&.>/ longLoc , <@]
>> >
>> >    'thisisatest'  lcs 'testing123testing'
>> > test
>> >
>> > I can easily imagine that this code could be further simplified.  If
>> > anyone sees any good simplifications, feel free to update rosettacode
>> > and/or post the details here.
>> >
>> > Thanks,
>> >
>> > --
>> > Raul
>> >
>> >
>> > On Thu, Jan 31, 2013 at 1:48 PM, Roger Hui <[email protected]> 
>> > wrote:
>> >>    t -: (2{.s) $ x /:&; </.i.s
>> >> 1
>> >>
>> >>
>> >>
>> >> On Thu, Jan 31, 2013 at 10:47 AM, Roger Hui 
>> >> <[email protected]>wrote:
>> >>
>> >>>    t=: 5 7 2 ?@$ 1e6
>> >>>    s=: $t
>> >>>    x=: </.t
>> >>>
>> >>>    t -: (2{.s) $ (;x)/:;</.i.s
>> >>> 1
>> >>>
>> >>>
>> >>>
>> >>> On Thu, Jan 31, 2013 at 10:28 AM, Raul Miller 
>> >>> <[email protected]>wrote:
>> >>>
>> >>>> Let's start with an arbitrary array:
>> >>>>
>> >>>>    A=: i. 2 3
>> >>>>
>> >>>> We can box oblique lines from this array:
>> >>>>
>> >>>>    </. A
>> >>>> +-+---+---+-+
>> >>>> |0|1 3|2 4|5|
>> >>>> +-+---+---+-+
>> >>>>
>> >>>> However, the interpreter does not currently provide us with an inverse
>> >>>> for this operation:
>> >>>>
>> >>>>    </.inv </. A
>> >>>> |domain error
>> >>>>
>> >>>> One problem is that you cannot uniquely determine the first two
>> >>>> elements of the shape of the original array by inspecting </.'s
>> >>>> result:
>> >>>>
>> >>>>    (</. 5 7$0) -: </.7 5$0
>> >>>> 1
>> >>>>
>> >>>> If its shape is provided, how might we reconstruct the original array?
>> >>>>
>> >>>> [For the sake of simple code, it's ok to focus on numeric, rank 2 
>> >>>> arrays.]
>> >>>>
>> >>>> --
>> >>>> Raul
>> >>>> ----------------------------------------------------------------------
>> >>>> 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
>
> ----------------------------------------------------------------------
> 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