From: Lloyd Linklater Date: 2007-05-11T23:51:39+09:00 Subject: Re: how to remove dups from 2 lists? Kevin Compton wrote: > I think a big part of it is that there are variations in what we assume > the > questioner wanted. > > In my case, I interpreted it as: > 1) remove items that appear in both lists from both lists > For instance, removeDups ([a, b, c, d], [b, d, f, g]) => [a, c], > [f, > g] > 2) don't go so far as remove more than the common count of dups > For instance, removeDups ([a, a, b, b, c, d, d], [b, d, d, d, f, g, > g]) > => [a, a, b, c], [d, f, g, g] > 3) keep the lists in original order (probably not required but I'm not > sure) > > I guess, it would be nice to have had the *need* demonstrated via > example or > clearly stated.. > but its been fun. I have to say that I am almost certainly being simplistic here but why cannot we do something like this: a = [1, 2, 3, 4] b = [2, 4, 6, 8] p a p b c = a & b a = a - c b = b - c p c p a p b result: [1, 2, 3, 4] [2, 4, 6, 8] [2, 4] [1, 3] [6, 8] -- Posted via http://www.ruby-forum.com/.