📘 Cross-product operator X in Perl 6

X is the cross product operator, which converts the two given lists to a third one containing all the possible combinations of the elements from the original lists.

@c = @a X @b;

This is the same as the following sequence:

@c = ((@a[0], @b[0]), (@a[0], @b[1]), (@a[0], @b[2]), ... (@a[N], @b[0]), (@a[N], @b[1]), ... (@a[N], @b[M]));

The length of the two operands can be different (they are N and M in the example above).

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