diff options
| author | Yukihiro "Matz" Matsumoto <[email protected]> | 2015-06-23 14:51:36 +0900 |
|---|---|---|
| committer | Yukihiro "Matz" Matsumoto <[email protected]> | 2015-06-23 14:51:36 +0900 |
| commit | 29a7226d8ebb5b998c2e5664215554f4dd23f588 (patch) | |
| tree | 061c906b477adcd8875bac1035a8922ee2b56d92 /mrbgems/mruby-proc-ext/mrblib | |
| parent | 66a352c836c4ab246cf6d30f6fa4eb353202c675 (diff) | |
| parent | 69b4c1648a71d7c275a98de7b9ebdc635a5fe438 (diff) | |
| download | mruby-29a7226d8ebb5b998c2e5664215554f4dd23f588.tar.gz mruby-29a7226d8ebb5b998c2e5664215554f4dd23f588.zip | |
Merge pull request #2849 from cremno/proc-curry-should-preserve-lambdas
Proc#curry should preserve lambdas
Diffstat (limited to 'mrbgems/mruby-proc-ext/mrblib')
| -rw-r--r-- | mrbgems/mruby-proc-ext/mrblib/proc.rb | 4 |
1 files changed, 3 insertions, 1 deletions
diff --git a/mrbgems/mruby-proc-ext/mrblib/proc.rb b/mrbgems/mruby-proc-ext/mrblib/proc.rb index 5dd9981df..b71663938 100644 --- a/mrbgems/mruby-proc-ext/mrblib/proc.rb +++ b/mrbgems/mruby-proc-ext/mrblib/proc.rb @@ -13,9 +13,11 @@ class Proc end def curry(arity=self.arity) + type = :proc abs = lambda {|a| a < 0 ? -a - 1 : a} arity = abs[arity] if lambda? + type = :lambda self_arity = self.arity if (self_arity >= 0 && arity != self_arity) || (self_arity < 0 && abs[self_arity] > arity) @@ -25,7 +27,7 @@ class Proc pproc = self make_curry = proc do |given_args=[]| - proc do |*args| + send(type) do |*args| new_args = given_args + args if new_args.size >= arity pproc[*new_args] |
