> 
> =head1 ABSTRACT
> 
> When programming in perl we need really often to calculate
> union, intersection, difference between arrays. It will be
> cool if such functions could be part of the perl6 language.


Arrays/Lists are ordered, sets are not.

For sets, hashes are a better perl representation.

- union
- intersection
- difference

Let's say you have a C<set> package and your sets are references to hashes
that have a 1 in every key that is in the set.



        sub union($$){

                return {%{$_[0]},%{$_[0]}}
        };

        sub intersection($$){

                my $int = {};
                for (keys %{$_[0]}){
                        $$_[1]{$_} and $$int{$_} = 1;
                };
                return $int;
        };


See?


-- 
                          David Nicol 816.235.1187 [EMAIL PROTECTED]
       perl -e'@w=<>;for(;;){sleep print[rand@w]}' /usr/dict/words

Reply via email to