Does anyone happen to have implemented diff in Haskell?  Something like

diff :: Ord a -> [a] -> [a] -> [DiffElement a]

data DiffElement a =
      InBoth a
   |  InFirst a
   |  InSecond a

So for example 
   diff [1,2,3,4,5] [2,3,6,7,4] might return
      [InFirst 1,InBoth 2,InBoth 3,InSecond 6,InSecond 7,InBoth 4,InFirst 5]

It would try to make the output list as short as possible, while still maintaining 
that the
subsequence of InFirst and InBoth a's is the same as its first argument, while the 
subsequence
of InSecond and Both a's is the same as its second argument.  However it doesn't have 
to return
the shortest possible output list; it may be that it can compute one which is close to 
optimal
much faster.  Also if you'd rather have a hash function than Ord I can manage that.

Thanks if anyone can help, and save me a bit of work ...

George Russell
_______________________________________________
Haskell mailing list
[EMAIL PROTECTED]
http://www.haskell.org/mailman/listinfo/haskell

Reply via email to