Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
M
mruby
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Libraries
mruby
Commits
69b4c164
Commit
69b4c164
authored
Jun 22, 2015
by
cremno
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Proc#curry should preserve lambdas
parent
e344c6ab
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
6 additions
and
1 deletion
+6
-1
mrbgems/mruby-proc-ext/mrblib/proc.rb
mrbgems/mruby-proc-ext/mrblib/proc.rb
+3
-1
mrbgems/mruby-proc-ext/test/proc.rb
mrbgems/mruby-proc-ext/test/proc.rb
+3
-0
No files found.
mrbgems/mruby-proc-ext/mrblib/proc.rb
View file @
69b4c164
...
...
@@ -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
]
...
...
mrbgems/mruby-proc-ext/test/proc.rb
View file @
69b4c164
...
...
@@ -41,6 +41,9 @@ assert('Proc#curry') do
assert_raise
(
ArgumentError
)
{
b
.
curry
[
1
,
2
][
3
,
4
]
}
assert_raise
(
ArgumentError
)
{
b
.
curry
(
5
)
}
assert_raise
(
ArgumentError
)
{
b
.
curry
(
1
)
}
assert_false
(
proc
{}.
curry
.
lambda?
)
assert_true
(
lambda
{}.
curry
.
lambda?
)
end
assert
(
'Proc#parameters'
)
do
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment