Sha256: 190a699a7aa7e8cd66c80ce589d574aa21f1bee00a87f6570a082fa591134f44
Contents?: true
Size: 1014 Bytes
Versions: 1
Compression:
Stored size: 1014 Bytes
Contents
# frozen_string_literal: true 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
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
combinatorics-0.5.0 | lib/combinatorics/cartesian_product/cardinality.rb |