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
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -370,7 +370,7 @@ R.pluck('v1', [obj1, obj2]) # [1, 3]
```

- [x] prepend
- [ ] product
- [x] product
- [x] project

```python
Expand Down Expand Up @@ -422,7 +422,7 @@ R.slice(1, None, ['a', 'b', 'c', 'd']) # ['b', 'c', 'd']
- [ ] splitWhenever
- [ ] startsWith
- [ ] subtract
- [ ] sum
- [x] sum
- [ ] symmetricDifference
- [ ] symmetricDifferenceWith
- [x] T
Expand Down
2 changes: 2 additions & 0 deletions ramda/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@
from .pipe import pipe
from .pluck import pluck
from .prepend import prepend
from .product import product
from .project import project
from .prop import prop
from .props import props
Expand All @@ -69,6 +70,7 @@
from .reverse import reverse
from .slice import slice
from .sort import sort
from .sum import sum
from .T import T
from .tail import tail
from .toString import toString
Expand Down
4 changes: 4 additions & 0 deletions ramda/product.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
from .multiply import multiply
from .reduce import reduce

product = reduce(multiply, 1)
4 changes: 4 additions & 0 deletions ramda/sum.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
from .add import add
from .reduce import reduce

sum = reduce(add, 0)
17 changes: 17 additions & 0 deletions test/test_product.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@

import unittest

import ramda as R

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


class TestT(unittest.TestCase):
def test_multiplies_together_the_array_of_numbers_supplied(self):
self.assertEqual(24, R.product([1, 2, 3, 4]))


if __name__ == '__main__':
unittest.main()
21 changes: 21 additions & 0 deletions test/test_sum.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@

import unittest

import ramda as R

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


class TestSum(unittest.TestCase):
def test_adds_together_the_array_of_numbers_supplied(self):
self.assertEqual(10, R.sum([1, 2, 3, 4]))

def test_does_not_save_the_state_of_the_accumulator(self):
self.assertEqual(10, R.sum([1, 2, 3, 4]))
self.assertEqual(1, R.sum([1]))
self.assertEqual(25, R.sum([5, 5, 5, 5, 5]))

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