Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -540,7 +540,7 @@ Partially supported
- [ ] tryCatch
- [ ] type
- [ ] unapply
- [ ] unary
- [x] unary
- [ ] uncurryN
- [ ] unfold
- [x] 0.1.2 union
Expand Down
1 change: 1 addition & 0 deletions ramda/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,7 @@
from .tap import tap
from .times import times
from .toString import toString
from .unary import unary
from .union import union
from .unionWith import unionWith
from .uniq import uniq
Expand Down
4 changes: 4 additions & 0 deletions ramda/unary.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
from .nAry import nAry
from .private._curry1 import _curry1

unary = _curry1(lambda fn: nAry(1, fn))
20 changes: 20 additions & 0 deletions test/test_unary.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@

import unittest

import ramda as R
from ramda.private._inspect import funcArgsLength

"""
https://github.com/ramda/ramda/blob/master/test/unary.js
"""


class TestUnary(unittest.TestCase):
def test_turns_multiple_argument_function_into_unary_one(self):
fn = R.unary(lambda *args: list(args))
self.assertEqual(1, funcArgsLength(fn))
self.assertEqual([1], fn(1, 2, 3))


if __name__ == '__main__':
unittest.main()