Sha256: 632e15fd105a3a2968ef2fef6ecbc4ceb5ae4a9821f85193d2f1cf8aad6935da
Contents?: true
Size: 983 Bytes
Versions: 3
Compression:
Stored size: 983 Bytes
Contents
module Combinatorics # # @author duper <super@manson.vistech.net> # # @since 0.4.0 # module CartesianProduct # # Wrapper for Cartesian product cardinality method defined above # # @param [Fixnum] a # Cardinality of first set. # # @param [Fixnum] b # Cardinality of second set. # # @raise [RangeError] # Inputs must be greater than zero. # # @return [Fixnum] # Length of enumeration resulting from a Cartesian product. # # @example Calculate elements in Cartesian product of two equal-size sets # cardinality(3, 4) # # => 12 # def self.cardinality(a,b) if (a <= 0 || b <= 0) raise(RangeError,"inputs must be greater than zero") end a * b end # # @note The letter `X' is scholastic notation for the Cartesian product # set operation # # @see cardinality # def self.X(a,b) cardinality(a,b) end end end
Version data entries
3 entries across 3 versions & 1 rubygems