> > =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
- Re: RFC 179 (v1) More functions... Tom Christiansen
- Re: RFC 179 (v1) More functions... Chaim Frenkel
- Re: RFC 179 (v1) More functions... Tom Christiansen
- Re: RFC 179 (v1) More functions... Tom Christiansen
- Please take RFC 179 discussion ... skud
- Re: Please take RFC 179 discuss... Gael Pegliasco
- Re: Please take RFC 179 discuss... Jeremy Howard
- Re: RFC 179 (v1) More functions... Piers Cawley
- Re: RFC 179 (v1) More functions... Gael Pegliasco
- Re: RFC 179 (v1) More functions... John Porter
- Re: RFC 179 (v1) More functions from set theory to manipu... David L. Nicol
- Re: RFC 179 (v1) More functions from set theory to manipu... Eric Roode
- Re: RFC 179 (v1) More functions from set theory to m... Gael Pegliasco
- Re: RFC 179 (v1) More functions from set theory to manipu... Eric Roode
- Re: RFC 179 (v1) More functions from set theory to m... John Porter
- Re: RFC 179 (v1) More functions from set theory ... Tom Christiansen
- Re: RFC 179 (v1) More functions from set theory to manipu... Eric Roode
- Re: RFC 179 (v1) More functions from set theory to m... Tom Christiansen
- Re: RFC 179 (v1) More functions from set theory ... Chaim Frenkel
- Re: RFC 179 (v1) More functions from set the... Tom Christiansen