class PGroup {
    constructor(members) {
        this.members = members;
    }

    add(elem) {
        if (this.has(elem)) return this;
        return new PGroup(this.members.concat(elem));
    }

    delete(elem) {
        if (!this.has(elem)) return this;
        return new PGroup(this.members.filter(e => e !== elem));
    }

    has(elem) {
        return this.members.includes(elem);
    }
}

PGroup.empty = new PGroup([]);

class PGroup {
	constructor(array) {
		this.members = array;
	}

	add(element) {
		return new PGroup(this.members.slice().push(element));
	}

	delete(element) {
		return new PGroup(this.members.filter(e => e !== element));
	}

	has(element) {
		return this.members.includes(element);
	}
}

PGroup.empty = new PGroup([]);

Add chapter 7, exercise 3
Add chapter 7, exercise 3
