Sha256: c68396304c521e0291b8098ae789e1b6cee3eefdc372bb4dd42b2ea8ec383c3e
Contents?: true
Size: 427 Bytes
Versions: 2
Compression:
Stored size: 427 Bytes
Contents
module LambdaDriver::Currying def curry 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
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
lambda_driver-1.1.0 | lib/lambda_driver/currying.rb |
lambda_driver-1.0.0 | lib/lambda_driver/currying.rb |