Last active
September 11, 2015 01:21
-
-
Save stevensona/dc6e732462f9f22a5581 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Parameter | |
attr_accessor :value | |
def initialize(value, update) | |
@value = value | |
@update = update | |
end | |
def update | |
@value = @update.call | |
end | |
def to_s | |
@value.to_s | |
end | |
end | |
$sim = Hash.new | |
def val(param) | |
$sim[param].value | |
end | |
$sim = { | |
heatIn: Parameter.new(2, Proc.new {val(:heatIn) + 1}), | |
heatOut: Parameter.new(1, Proc.new {val :heatOut}), | |
temp: Parameter.new(100, Proc.new {val(:temp) + val(:heatIn) - val(:heatOut)}) | |
} | |
5.times do |i| | |
puts "cycle #{i}" | |
$sim.each do |n, p| | |
p.update | |
puts p | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment