Skip to content

intersection #23

Open
Open
@stephanelsmith

Description

@stephanelsmith

intersection doesn't seem to perform correctly. Intersecting a simple list of strings results in [].

Simple fix was to remove the first 4 lines where there's a test for 'int', then a wrap into a tuple. Not sure what the purpose of that is for, but intersection seems to work without.

def intersection(self, *args):
    """
    Produce an array that contains every item shared between all the
    passed-in arrays.
    """
    # if type(self.obj[0]) is int:
        # a = self.obj
    # else:
        # a = tuple(self.obj[0])
    setobj = set(self.obj)
    for i, v in enumerate(args):
        setobj = setobj & set(args[i])
    return self._wrap(list(setobj))

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions