I have been working on the longest common subsequence
problem.  A detailed article exists here:

http://en.wikipedia.org/wiki/Longest_common_subsequence

Examining Table C of the example, I decided to work
not with a full matrix but instead with comparison of
indices.  The example they chose can be built so:

   S0=. 'XMJYAUZ'
   S1=. 'MZJAWXU'
   It=: (\:~~ +/@|:) 4$.$. S0 =/ S1

It, the indices of ones in the equality table, is:

5 6
4 3
6 1
0 5
2 2
1 0

What I want from this are the items where each index
is less than the index of the good items above it. The
difficulty is that bad items make it difficult to
qualify later items.

The following function results in a boolean list where
the first zero is the first item to be omitted:

ff=: 1,*./@|:@ 2&(>/\)

Perhaps here I have a situation where a traditional
loop would be best.  Before I break down and do that,
though, I'm asking for advice on a loopless approach.

I looked at chapter 25 of JfC, and at the Do While
essay on the J Wiki.  I have not thought of a way to
apply either technique here, but the Do-While use of
Power seems more promising.  (The JfC solution seems
oriented to accommodate more special considerations
than we have here.)  I have a vague idea that we might
do a copy on each iteration, excluding the first
misfit item found before continuing on.

It may help for me to say a bit more about the
solution being pursued.  What I'm missing is a way to
produce the Boolean list portion of the following
definition:

solIt=. |. 1 1 0 0 1 1 # It

That produces a solution that can be interpreted from
either of the original character vectors.

   (0{"1 solIt){S0   NB. solution, Wikepedia example
   (1{"1 solIt){S1   NB. same solution

Thank you,


--
Tracy B. Harms
 
     A good programming language is a conceptual universe
     for thinking about programming.
                                        Alan Perlis


      
____________________________________________________________________________________
Be a better friend, newshound, and 
know-it-all with Yahoo! Mobile.  Try it now.  
http://mobile.yahoo.com/;_ylt=Ahu06i62sR8HDtDypao8Wcj9tAcJ
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm

Reply via email to