This file contains hidden or 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
lambda { | |
setups = [] | |
events = {} | |
Kernel.send :define_method, :event do |name, &block| | |
events[name] = block | |
end | |
Kernel.send :define_method, :setup do |&block| | |
setups << block | |
end |
This file contains hidden or 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
# given class Computer: refactor me | |
class Computer | |
def initialize(computer_id, data_source) | |
@id = computer_id | |
@data_source = data_source | |
end | |
def mouse | |
info = @data_source.get_mouse_info(@id) | |
price = @data_source.get_mouse_price(@id) |
This file contains hidden or 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
# D subset |R Domain over which we integrate - sample D = [1,10] | |
D = (1..10).to_a | |
# f:|R->|R function - sample x |-> f(x) := x^2 | |
f = lambda {|x| x*x} | |
# summation of function values over our domain | |
summator = lambda {|function, domain| domain.inject(0){|x,y| x += function.call(y)} } | |
# Integrations Driver (for real valued 1d functions only) - assumption: integration steps equidistant |
NewerOlder