Z = ->(f) {
->(x) {
f[ ->(y) { x[x][y] } ]
}[
->(x) {
f[ ->(y) { x[x][y] } ]
}
]
}
class Proc
def ==(other)
RubyVM::InstructionSequence.of(self) == RubyVM::InstructionSequence.of(other)
end
end
s = ->(x) { ->(y) { ->(z) { x[z][y[z]] }}}
k = ->(x) { ->(y) { x }}
s[Z[s]] == Z[s]
#=> true
k[Z[k]] == Z[k]
#=> true
1000.times.all? do
f = eval rand(1000).times.inject("s") { |f| f + %w|[s] [k]|.sample }
f[Z[f]] == Z[f]
end
#=> true
Last active
August 29, 2015 14:12
-
-
Save gogotanaka/b8c5688863d9c4774cd8 to your computer and use it in GitHub Desktop.
Zコンビネーター、Ruby
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment