summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--state.rb11
1 files changed, 11 insertions, 0 deletions
diff --git a/state.rb b/state.rb
index 011567b..b69421a 100644
--- a/state.rb
+++ b/state.rb
@@ -5,6 +5,17 @@ Author: Casey Dahlin <cjdahlin@ncsu.edu>
=end
require 'set'
+unless Array.instance_methods.include? "product"
+ class Array #:nodoc:
+ def product(*others)
+ return self.map{ |x| [x] } if others.size == 0
+ self.map do |x|
+ (others[0].product(*others[1..-1])).map{ |y| [x] + y }
+ end.inject([]){ |x,y| x+y }
+ end
+ end
+end
+
module UpState
# Occurs when the state machine becomes inconsistent