class Object
def choices(choicelist)
if (!Class.class_variables.include? "@@cont")
@@cont = []
end
choicelist.each { |choice|
callcc { |cc|
@@cont << cc
return choice
}
}
nil
end
def condition(cond)
return if (self.class == NilClass?)
@@cont.pop.call if !cond.call
end
end
class NilClass?
def method_missing(methId, *args)
return false
end
end
foo = choices(1..100)
bar = choices(1..100)
condition(lambda{foo == (bar * 3)})
condition(lambda{bar > 10})
condition(lambda{(bar % 2) == 0})
puts foo
puts bar
Thanks for your help.