Proposal: SuperSet

Григорий Карелин grundiss at gmail.com
Tue Jul 9 20:04:49 UTC 2019


Maybe add those methods into Set instead of creating new type?

On Tue, 9 Jul 2019 at 23:02, Oğuz Kılıç <oguzz.kilic at gmail.com> wrote:

> As you know, the current Set feature is not sufficient in some aspects. We
> benefit from utility libraries or special implementations to fill this
> deficiency.
>
> For example, wouldn’t it be better if we had the following approach?
>
> UNION
>
> X ∪ Y = { x | x ∈ X or x ∈ Y }
>
> let first = new SuperSet(["a", "b", "c"]);
> let second = new SuperSet(["b", "c", "d", "e"]);
>
> first.union(second); //→ SuperSet { "a", "b", "c", "d", "e" }
>
> DIFFERENCE
>
> X - Y = { x | x ∈ X and x ∉ Y }
>
> let nums = new SuperSet([3, 4, 5, 6]);
> let primes = new SuperSet([2, 3, 5, 7]);
>
> nums.diff(primes); // → SuperSet { 4, 6 }
>
> INTERSECT
>
> X ∩ Y = { x | x ∈ X and x ∈ Y }
>
> let nums = new SuperSet([3, 4, 5, 6]);
> let primes = new SuperSet([2, 3, 5, 7]);
> nums.intersect(primes); // → SuperSet { 3, 5 }
>
> DISCARD
>
> let nums = new SuperSet([1, 2, 3, 4]);
> nums.discard([1, 3]); // → SuperSet { 2, 4 }
>
> Motivation
> SuperSet - https://github.com/BYK/superset
> _______________________________________________
> es-discuss mailing list
> es-discuss at mozilla.org
> https://mail.mozilla.org/listinfo/es-discuss
>
-- 
Отправлено с мобильного устройства
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.mozilla.org/pipermail/es-discuss/attachments/20190709/a9436ab5/attachment.html>


More information about the es-discuss mailing list