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

%hash1 >>...<< %hash2

Thread Next
From:
David Formosa
Date:
June 14, 2005 00:33
Subject:
%hash1 >>...<< %hash2
Message ID:
slrndasshv.1v7.dformosa@dformosa.zeta.org.au
	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
http://dformosa.zeta.org.au/~dformosa/Spelling.html to find out more.
Free the Memes.

Thread Next


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About