Symmetric difference set operation · Issue #63 · SFTtech/nyan · GitHub
Skip to content

Symmetric difference set operation #63

Open

Description

@heinezen

Symmetric difference, disjunctive union, XOR - or whatever you call it - is a set operation where the resulting set is composed of elements which are present in either set, but not in both. The corresponding python operator is ^=.

This operation would lower the required patches for "replacement" changes such as the replacement of a move ability.

Without XOR (2 patches):

PatchRemove<SomeUnit>(..):
    abilities -= {OldMove}

PatchAdd<SomeUnit>(..):
    abilities += {NewMove}

With XOR (1 patch):

PatchXOR<SomeUnit>(..)
    # OldMove will be removed because it is in both sets
    abilities ^= {OldMove, NewMove}

Activity

  1. TheJJ commented on Aug 31, 2019

    @TheJJ
    Member

    We can add it, but I would be careful because if an unforseen mod already adds an ability you want to add know, the ^= will remove it then even though you intended to add it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions