Re: Generalizing Complement to handle multiple occurrences of elements
- To: mathgroup at smc.vnet.net
- Subject: [mg112468] Re: Generalizing Complement to handle multiple occurrences of elements
- From: Ray Koopman <koopman at sfu.ca>
- Date: Thu, 16 Sep 2010 06:01:33 -0400 (EDT)
- References: <i6q0ml$l7c$1@smc.vnet.net>
On Sep 15, 1:38 am, Mark Coleman <markspcole... at gmail.com> wrote: > Greetings, > > I'm wondering how one can efficiently generalize the built-in > Complement function to return multiple occurrences of elements. For > instance, the current version generates > > a={1,2,2,3,4,4,4,4} > b={3,5,7} > > Complement[a,b]={1,2,4} > > I'm looking for a way to define > > myComplement[a,b]={1,2,2,4,4,4,4} > > My current code is very inefficient! > > Thanks, > > Mark What do you want myComplement[{1,2,2,3,4,4,4,4}, {1,2, 4,4, 5,7}] to return: {2,3,4,4} or {3}?