πŸ“˜ Junction operators |, &, and ^ in Perl 6

|, &, and ^ create the so-called junctions (formerly known in Perl 6 as quantum superpositions). These objects can be used where a scalar is used but behave differently; unlike the scalars, the junctions have multiple values at the same moment in time.

The |, &, and ^ operators create, respectively, the junctions of the any, all, and one types.

# The value of 4 is one of the listed options
say "ok" if 4 == 1|2|3|4|5;Β Β 

# There is no 4 in the list
say "ok" if 4 != 1 & 2 & 3 & 5; Β 

# 4 repeats twice, thus it is not unique
say "ok" unless 4 == 1 ^ 2 ^ 2 ^ 4 ^ 4 ^ 5;

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s