3 deleted 21 characters in body

## Haskell, 454142 bytes

y#(e:s)=[e|elem e =[e|any(==e)y,all(/=e)s]++y#s
_#x=x


Edit: -2 bytes thanks to @Ørjan Johansen, -1 byte thanks to @dfeuer and -1 byte by myself.

## Haskell, 4541 bytes

y#(e:s)=[e|elem e y,all(/=e)s]++y#s
_#x=x


Try it online!

Edit: -2 bytes thanks to @Ørjan Johansen, -1 byte thanks to @dfeuer and -1 byte by myself.

## Haskell, 4542 bytes

y#(e:s)=[e|any(==e)y,all(/=e)s]++y#s
_#x=x


Try it online!

Edit: -2 bytes thanks to @Ørjan Johansen, -1 byte thanks to @dfeuer.

2 deleted 22 characters in body

## Haskell, 4545 41 bytes

f y=foldly#(\s e->s++[e|any(==e:s)=[e|elem e y,all(/=e)s])[]s]++y#s
_#x=x


Example usage: f [3,1,2,4,3,1,1,1,1,3] [3,1,-1,0,8,3,3,1] -> [3,1].Try it online!

Starting with the empty list as an accumulator go through one of the input lists and add it's elements to the accumulator if it's in the other list but not in the accumulator so far. Membership of e inEdit: y is tested with-2 bytes thanks to @Ørjan Johansen, any(==e)y. Not-membership with1 byte thanks to @dfeuer and all(/=e)y-1 byte by myself.

## Haskell, 45 bytes

f y=foldl(\s e->s++[e|any(==e)y,all(/=e)s])[]


Example usage: f [3,1,2,4,3,1,1,1,1,3] [3,1,-1,0,8,3,3,1] -> [3,1].

Starting with the empty list as an accumulator go through one of the input lists and add it's elements to the accumulator if it's in the other list but not in the accumulator so far. Membership of e in y is tested with any(==e)y. Not-membership with all(/=e)y.

## Haskell, 45 41 bytes

y#(e:s)=[e|elem e y,all(/=e)s]++y#s
_#x=x


Try it online!

Edit: -2 bytes thanks to @Ørjan Johansen, -1 byte thanks to @dfeuer and -1 byte by myself.

1

## Haskell, 45 bytes

f y=foldl(\s e->s++[e|any(==e)y,all(/=e)s])[]


Example usage: f [3,1,2,4,3,1,1,1,1,3] [3,1,-1,0,8,3,3,1] -> [3,1].

Starting with the empty list as an accumulator go through one of the input lists and add it's elements to the accumulator if it's in the other list but not in the accumulator so far. Membership of e in y is tested with any(==e)y. Not-membership with all(/=e)y.