Skip to content

Commit aab7fbc

Browse files
authored
Merge pull request #125 from zydmayday/unary
add method unary
2 parents 8ef691c + 54d150d commit aab7fbc

File tree

4 files changed

+26
-1
lines changed

4 files changed

+26
-1
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -540,7 +540,7 @@ Partially supported
540540
- [ ] tryCatch
541541
- [ ] type
542542
- [ ] unapply
543-
- [ ] unary
543+
- [x] unary
544544
- [ ] uncurryN
545545
- [ ] unfold
546546
- [x] 0.1.2 union

ramda/__init__.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,7 @@
9696
from .tap import tap
9797
from .times import times
9898
from .toString import toString
99+
from .unary import unary
99100
from .union import union
100101
from .unionWith import unionWith
101102
from .uniq import uniq

ramda/unary.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
from .nAry import nAry
2+
from .private._curry1 import _curry1
3+
4+
unary = _curry1(lambda fn: nAry(1, fn))

test/test_unary.py

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
2+
import unittest
3+
4+
import ramda as R
5+
from ramda.private._inspect import funcArgsLength
6+
7+
"""
8+
https://github.com/ramda/ramda/blob/master/test/unary.js
9+
"""
10+
11+
12+
class TestUnary(unittest.TestCase):
13+
def test_turns_multiple_argument_function_into_unary_one(self):
14+
fn = R.unary(lambda *args: list(args))
15+
self.assertEqual(1, funcArgsLength(fn))
16+
self.assertEqual([1], fn(1, 2, 3))
17+
18+
19+
if __name__ == '__main__':
20+
unittest.main()

0 commit comments

Comments
 (0)