Set consolidation: Difference between revisions
Content added Content deleted
(→{{header|Perl 6}}: use more compact conditional) |
(→{{header|Perl 6}}: use empty list for degenerate case rather than single item, use pronouns instead of x and y) |
||
Line 239: | Line 239: | ||
=={{header|Perl 6}}== |
=={{header|Perl 6}}== |
||
{{works with|niecza|2012-06}} |
{{works with|niecza|2012-06}} |
||
<lang perl6>multi consolidate( |
<lang perl6>multi consolidate() { () } |
||
multi consolidate(Set |
multi consolidate(Set \this is copy, *@those) { |
||
gather { |
gather { |
||
for consolidate |@ |
for consolidate |@those -> \that { |
||
if +( |
if +(this ∩ that) { this ∪= that } |
||
else { take |
else { take that } |
||
} |
} |
||
take |
take this; |
||
} |
} |
||
} |
} |