develooper Front page | perl.perl6.language | Postings from August 2006

Re: Pair of lists => list of pairs?

Thread Previous | Thread Next
Larry Wall
August 23, 2006 15:13
Re: Pair of lists => list of pairs?
Message ID:
On Wed, Aug 23, 2006 at 05:43:48PM -0400, Mark J. Reed wrote:
: Suppose I have two arrays @k and @v and I want to declare and initialize a
: hash %h such that %h.keys eqv @k and %h.values eqv @v.
: I could use a direct translation of the P5 idiom:
: my %h;
: %h{@k} = @v;
: But is there an easy way in Perl6 to do it all in one go?  Should this work?
: my %h = @k [=>] @v;

Reduce operators only turn infix into list operators.  What you really
want here is a hyper-fatarrow:

    my %h = @k »=>« @v;


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