Skip to content

Comment on Y Combinator in Python

Comments

    # Ruby 1.8.7
    def Y
      lambda { |f| f.call(f) }.call(
        lambda do |g|
          yield(lambda { |*n| g.call(g).call(*n) })
        end)
    end
    Y { |this| lambda { |n| n == 0 ? 1 : n * this.call(n - 1) } }.call(5)
    #=> 120
AboutSource Built by g1lg1l

Hackerly is an independent reader for Hacker News, built on the public HN API. Not affiliated with Y Combinator.