Created
May 25, 2016 07:41
-
-
Save JonathonMA/eacea8bf6a25d11a826b489fd1e766f1 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
module ExponentialBackoffStrategyModule | |
module_function def call(exponent, value) | |
value ** exponent | |
end | |
end | |
class ExponentialBackoffStrategyClass | |
def initialize(exponent) | |
@exponent = exponent | |
end | |
def call(value) | |
value ** @exponent | |
end | |
end | |
curried = ExponentialBackoffStrategyModule.method(:call).curry.(4) | |
partialed = ->(x) { ExponentialBackoffStrategyModule.call(4, x) } | |
lambdad = ->(x) { x ** 4 } | |
klassed = ExponentialBackoffStrategyClass.new(4) | |
require 'fruity' | |
compare do | |
curry { curried.call(10) } | |
klass { klassed.call(10) } | |
partial { partialed.call(10) } | |
λ { lambdad.call(10) } | |
end |
Author
JonathonMA
commented
May 25, 2016
•
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment