Last active
August 29, 2015 14:02
-
-
Save js947/560551480f6930a0dac2 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
def frk a, r, b | |
lambda do |x| | |
r.call(a.call(x), b.call(x)) | |
end | |
end | |
def sum a | |
a.reduce(0) do |sum, value| | |
sum + value | |
end | |
end | |
sum = method :sum | |
def cnt a | |
a.length | |
end | |
cnt = method :cnt | |
def div a, b | |
a/b | |
end | |
div = method :div | |
avg = frk sum, div, cnt | |
ans = avg.call [1.0, 2.0, 3.0, 4.0] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment