develooper Front page | perl.perl6.users | Postings from July 2017

set (+) set = bag ?

Thread Next
From:
Gabor Szabo
Date:
July 21, 2017 12:03
Subject:
set (+) set = bag ?
Message ID:
CABe4FJBx-FY7L=dDrNm3o1EnP7q+0OBmJWa5dNaVCULH_KMJKw@mail.gmail.com
Looking at Sets https://docs.perl6.org/type/Set

I was happy to see (-) to work as I expected, but I was surprised to see
that (+) created a bag. Is that intentional? How can I get back the
set. Is the only way using the unicode character ∪ ?

(This is Rakudo version 2017.04.3 so I might be behind the times on this.)


$ perl6
To exit type 'exit' or '^D'
> my $a = set('a','b')
set(b, a)
> my $b = set('a', 'c')
set(a, c)

> $a
set(b, a)
> $b
set(a, c)

> $a (-) $b
set(b)
> $b (-) $a
set(c)


> $a (+) $b
bag(b, a(2), c)

> $a ∪ $b
set(b, a, c)

Gabor

Thread Next


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About