Sha256: 88a4ad03b56e88ad4f75546b43dd985a700e4d435fd0d16a21f9c8b4769d22b2

Contents?: true

Size: 592 Bytes

Versions: 10

Compression:

Stored size: 592 Bytes

Contents

require 'facets/na'

class Proc

  # Convert a Proc object into new partial Proc object.
  #
  #   a = proc { |a,b,c| a+b+c }
  #   b = a.partial(NA,2,NA)
  #   b[1,3] #=> 6
  #
  # Note, the #__ method, which used to be used in stay of NA,
  # has been deprecated.
  #
  #--
  #   a = proc { |a,b,c| a+b+c }
  #   b = a.partial(__,2,__)
  #   b[1,3] #=> 6
  #++
  #
  # This method is similar to Proc#curry.
  #
  # CREDT Trans

  def partial(*args)
    Proc.new do |*spice|
      result = args.collect do |a|
        NA == a ? spice.pop : a
      end
      call(*result)
    end
  end

end

Version data entries

10 entries across 9 versions & 2 rubygems

Version Path
facets-glimmer-3.2.0 lib/core/facets/proc/partial.rb
facets-3.1.0 lib/core/facets/proc/partial.rb
facets-3.0.0 lib/core/facets/proc/partial.rb
facets-2.9.3 lib/core/facets/proc/partial.rb
facets-2.9.2 lib/core/facets/proc/partial.rb
facets-2.9.2 src/core/facets/proc/partial.rb
facets-2.9.1 lib/core/facets/proc/partial.rb
facets-2.9.0 lib/core/facets/proc/partial.rb
facets-2.9.0.pre.2 lib/core/facets/proc/partial.rb
facets-2.9.0.pre.1 lib/core/facets/proc/partial.rb