On 5/11/07, Lloyd Linklater <lloyd / 2live4.com> wrote:
> 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/.
>
>
What happens here? :)
All 5's are deleted.
I don't know if that is what he wants but I interpreted it differently.

a = [1, 2, 3, 4, 5, 5, 5]
b = [2, 4, 6, 8, 5]

p a
p b

c = a & b
a = a - c
b = b - c

p c
p a
p b

Harry

-- 
http://www.kakueki.com/ruby/list.html
A Look into Japanese Ruby List in English