develooper Front page | perl.perl6.language | Postings from June 2005

%hash1 >>...<< %hash2

Thread Next
David Formosa
June 14, 2005 00:33
%hash1 >>...<< %hash2
Message ID:
	This is inspired inpart by discussions I had on #perl6.
Basically what is the behavour of the hyperop when applied to two
hashes.  The concensus was that the hashes would get unrolled into
lists, and the pairs would get matched up more or less randomly.

	I don't feel that this is a usefull DWIMy behavour.  I think a
more usefull behavour is the following.  Pairs on both sides that have
common keys should have there values oped together and a hash
should be created from these.  The behavour would be something like
this (please forgive bugs).

multi sub infix_circumfix_meta_operator:{'>>','<<'} (Hash %a,Hash %b,Code $op) {
	my Hash %return;
	for intersection(keys %a,keys %b) -> $key {
	  %return{$key} = $op($a{$key},$b{$key});
	return %return;

	Would this be sensible, usefull behavour?

Please excuse my spelling as I suffer from agraphia. See to find out more.
Free the Memes.

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