Skip to content

Conversation

@allanrenucci
Copy link
Contributor

union on List is concatenation. Duplicates are not removed. Also union is deprecated in 2.13.

`union` on `List` is concatenation. Duplicates are not removed. Also
`union` is deprecated in 2.13.

/** Union on lists seen as sets */
def | (ys: List[T]): List[T] = xs ++ (ys filterNot (xs contains _))
def | (ys: List[T]): List[T] = xs ::: (ys filterNot (xs contains _))
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe we should do xs filterNot (ys contains _) ::: ys to always share the tail.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe. I did't want to change the semantic. Maybe ordering matters.

I suggest trying out optimisations in another PR. Definitely worth investigating!

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Agreed

Copy link
Contributor

@liufengyun liufengyun left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@allanrenucci allanrenucci merged commit 9ed0524 into scala:master Dec 10, 2018
@allanrenucci allanrenucci deleted the fix-union branch December 10, 2018 12:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants