Sha256: 5fc48b9665df248f0aae1cf67a3941322832c88a942bd829993bbf10db399eed
Contents?: true
Size: 442 Bytes
Versions: 3
Compression:
Stored size: 442 Bytes
Contents
module LambdaDriver::Currying def curry(arity = nil) f = self.to_proc arity ||= __arity(f) return f if arity == 0 lambda{|arg| __curry(f, arity, arg, []) } end private def __arity(f) (f.arity >= 0) ? f.arity : -(f.arity + 1) end def __curry(f, arity, arg, passed) args = passed + [arg] return f.call(*args) if arity == 1 lambda{|arg| __curry(f, arity - 1, arg, args) } end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
lambda_driver-1.2.0 | lib/lambda_driver/currying.rb |
lambda_driver-1.1.2 | lib/lambda_driver/currying.rb |
lambda_driver-1.1.1 | lib/lambda_driver/currying.rb |