Sha256: 290aa9a67bcb379bb8276d513e4113a9192e3820303b43110c6bbe5519086512
Contents?: true
Size: 446 Bytes
Versions: 4
Compression:
Stored size: 446 Bytes
Contents
module Kernel # Y-combinator. # # f = Y do |n, acc, &b| # n < 2 ? acc : b.(n-1, n * acc) # end # # f.call(5, 1) #=> 120 # # NOTE: This method is not a common core extension and is not # loaded automatically when using <code>require 'facets'</code>. # # CREDIT: Michael Fellinger # # @uncommon # require 'facets/kernel/y' # def Y(*args, &block) y = lambda{|*args| block.call(*args, &y) } end end
Version data entries
4 entries across 4 versions & 2 rubygems
Version | Path |
---|---|
facets-glimmer-3.2.0 | lib/core/facets/kernel/y.rb |
facets-3.1.0 | lib/core/facets/kernel/y.rb |
facets-3.0.0 | lib/core/facets/kernel/y.rb |
facets-2.9.3 | lib/core/facets/kernel/y.rb |