Skip to content

Instantly share code, notes, and snippets.

@jdoiwork
Created May 13, 2016 12:00
Show Gist options
  • Select an option

  • Save jdoiwork/133f5538bdc8fbaf5585f5eed84c6ac7 to your computer and use it in GitHub Desktop.

Select an option

Save jdoiwork/133f5538bdc8fbaf5585f5eed84c6ac7 to your computer and use it in GitHub Desktop.
class App
def plus1(n)
n + 1
end
def double(n)
n * 2
end
def triple(n)
[n, n, n]
end
def run(n)
[
:plus1,
:double,
:double,
:triple,
].reduce(n, &call)
end
def apply(x, f)
method(f).(x)
end
def call
method(:apply)
end
end
result = App.new.run(10)
p result
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment