June 2018 Update
This commit is contained in:
parent
ba8067c3b7
commit
22f33d4004
5278 changed files with 84726 additions and 14379 deletions
19
Task/Hash-from-two-arrays/Perl-6/hash-from-two-arrays.pl6
Normal file
19
Task/Hash-from-two-arrays/Perl-6/hash-from-two-arrays.pl6
Normal file
|
|
@ -0,0 +1,19 @@
|
|||
my @keys = <a b c d e>;
|
||||
my @values = ^5;
|
||||
|
||||
my %hash = @keys Z=> @values;
|
||||
|
||||
|
||||
#Alternatively, by assigning to a hash slice:
|
||||
%hash{@keys} = @values;
|
||||
|
||||
|
||||
# Or to create an anonymous hash:
|
||||
%( @keys Z=> @values );
|
||||
|
||||
|
||||
# All of these zip forms trim the result to the length of the shorter of their two input lists.
|
||||
# If you wish to enforce equal lengths, you can use a strict hyperoperator instead:
|
||||
|
||||
quietly # suppress warnings about unused hash
|
||||
{ @keys »=>« @values }; # Will fail if the lists differ in length
|
||||
Loading…
Add table
Add a link
Reference in a new issue