Beefy Boxes and Bandwidth Generously Provided by pair Networks
Problems? Is your data what you think it is?
 
PerlMonks  

xhunter's scratchpad

by xhunter (Sexton)
on Oct 14, 2005 at 20:02 UTC ( [id://500360]=scratchpad: print w/replies, xml ) Need Help??

=head1 Junctions Motivation: Ways to compare arrays via Junctions =cut use 5.0.10; use Perl6::Junction qw(any all one none); my @rainbow = qw(red orange yellow green blue indigo violet); if (any(@rainbow) eq 'indigo') { say "It's a go."; } =head1 Slices of Hash Motivation: Suppose you got a hash and you want a subset of the hash values. One can access those values via a hash slice. Mappings: function hash slice: hashes -> lists subset of keys |--> list of values. How: List the keys of the wanted values, but since the return is a list use @ instead of $ as the hash sigil. Example: Below =cut my %hash = qw( wednesday brown friday red saturday black ); my @weekend_hash = @hash{qw(friday saturday)}; print 'On the weekend she enjoys '; print join ', and ', @weekend_hash; print '.';
=pod Another example to show how one could set the values of a hash to a default value givens an array to act as the keys. =cut
my @grades = qw/ 0 1 2 3 /; my %student_count_by_grade; @student_count_by_grade{@grades} = (0) x 4;
Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others wandering the Monastery: (6)
As of 2024-04-23 10:58 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found