# Module: Combinatorics::CartesianProduct

Defined in:
lib/combinatorics/cartesian_product/cardinality.rb,
lib/combinatorics/cartesian_product/mixin.rb

Author:

Since:

• 0.4.0

Modules: Mixin

## Class Method Summary collapse

• Wrapper for Cartesian product cardinality method defined above.

## Class Method Details

### .cardinality(a, b) ⇒ Fixnum

Wrapper for Cartesian product cardinality method defined above

Examples:

Calculate elements in Cartesian product of two equal-size sets

``````cardinality(3, 4)
# => 12``````

Parameters:

• a (Fixnum)

Cardinality of first set.

• b (Fixnum)

Cardinality of second set.

Returns:

• (Fixnum)

Length of enumeration resulting from a Cartesian product.

Raises:

• (RangeError)

Inputs must be greater than zero.

Since:

• 0.4.0

 ``` 27 28 29 30 31 32 33``` ```# File 'lib/combinatorics/cartesian_product/cardinality.rb', line 27 def self.cardinality(a,b) if (a <= 0 || b <= 0) raise(RangeError,"inputs must be greater than zero") end a * b end```

### .X(a, b) ⇒ Object

Note:

The letter `X' is scholastic notation for the Cartesian product set operation

 ``` 41 42 43``` ```# File 'lib/combinatorics/cartesian_product/cardinality.rb', line 41 def self.X(a,b) cardinality(a,b) end```