RosettaCodeData/Task/Set-consolidation/Perl-6/set-consolidation.pl6
2014-01-17 05:34:36 +00:00

17 lines
502 B
Raku
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

multi consolidate() { () }
multi consolidate(Set \this is copy, *@those) {
gather {
for consolidate |@those -> \that {
if this that { this = this that }
else { take that }
}
take this;
}
}
enum Elems <A B C D E F G H I J K>;
say $_, "\n ==> ", consolidate |$_
for [set(A,B), set(C,D)],
[set(A,B), set(B,D)],
[set(A,B), set(C,D), set(D,B)],
[set(H,I,K), set(A,B), set(C,D), set(D,B), set(F,G,H)];