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

set (+) set = bag ?

Thread Next
Gabor Szabo
July 21, 2017 12:03
set (+) set = bag ?
Message ID:
Looking at Sets

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
> $b (-) $a

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

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


Thread Next Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at | Group listing | About