In Files

  • mrbgems/mruby-proc-ext/mrblib/proc.rb

Parent

Proc

Public Instance Methods

===(*args) click to toggle source
 
               # File mrbgems/mruby-proc-ext/mrblib/proc.rb, line 3
def ===(*args)
  call(*args)
end
            
curry(arity=self.arity) click to toggle source
 
               # File mrbgems/mruby-proc-ext/mrblib/proc.rb, line 15
def curry(arity=self.arity)
  abs = lambda {|a| a < 0 ? -a - 1 : a}
  arity = abs[arity]
  if lambda?
    self_arity = self.arity
    if (self_arity >= 0 && arity != self_arity) ||
       (self_arity < 0 && abs[self_arity] > arity)
      raise ArgumentError, "wrong number of arguments (#{arity} for #{abs[self_arity]})"
    end
  end

  pproc = self
  make_curry = proc do |given_args=[]|
    proc do |*args|
      new_args = given_args + args
      if new_args.size >= arity
        pproc[*new_args]
      else
        make_curry[new_args]
      end
    end
  end
  make_curry.call
end
            
to_proc() click to toggle source
 
               # File mrbgems/mruby-proc-ext/mrblib/proc.rb, line 11
def to_proc
  self
end
            
yield(*args) click to toggle source
 
               # File mrbgems/mruby-proc-ext/mrblib/proc.rb, line 7
def yield(*args)
  call(*args)
end
            

Commenting is here to help enhance the documentation. For example, code samples, or clarification of the documentation.

If you have questions about Ruby or the documentation, please post to one of the Ruby mailing lists. You will get better, faster, help that way.

If you wish to post a correction of the docs, please do so, but also file bug report so that it can be corrected for the next release. Thank you.

If you want to help improve the Ruby documentation, please visit Documenting-ruby.org.

blog comments powered by Disqus