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 @@ -478,7 +478,7 @@ R.propEq(1, 'v1', {'v1': 1}) # True
- [x] 0.1.2 reduceRight
- [ ] reduceWhile
- [x] 0.1.2 reject
- [ ] remove
- [x] remove
- [x] 0.1.4 repeat
- [ ] replace
- [x] 0.1.2 reverse
Expand Down
1 change: 1 addition & 0 deletions ramda/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,7 @@
from .reduced import reduced
from .reduceRight import reduceRight
from .reject import reject
from .remove import remove
from .repeat import repeat
from .reverse import reverse
from .slice import slice
Expand Down
3 changes: 3 additions & 0 deletions ramda/remove.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
from .private._curry3 import _curry3

remove = _curry3(lambda start, count, arr: arr[:start] + arr[start + count:])
30 changes: 30 additions & 0 deletions test/test_remove.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@

import unittest

import ramda as R

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

arr = ['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j']


class TestRemove(unittest.TestCase):
def test_splices_out_a_sub_list_of_the_given_list(self):
self.assertEqual(['a', 'b', 'h', 'i', 'j'], R.remove(2, 5, arr))

def test_returns_the_appropriate_sublist_with_start_0(self):
self.assertEqual(['f', 'g', 'h', 'i', 'j'], R.remove(0, 5, arr))
self.assertEqual(['b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j'], R.remove(0, 1, arr))
self.assertEqual([], R.remove(0, len(arr), arr))

def test_removes_the_end_of_the_list_if_the_count_is_too_large(self):
self.assertEqual(['a', 'b'], R.remove(2, 20, arr))

def test_retains_the_entire_list_if_the_start_is_too_large(self):
self.assertEqual(['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j'], R.remove(13, 3, arr))


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