Last active
August 30, 2018 14:52
-
-
Save codingedgar/d68c0b11db9607694425f40172c1095a to your computer and use it in GitHub Desktop.
until transducer: reduce_sum_reduce
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { sum_of_every_element } from './sum_of_every_element' | |
test('calculate the sum of all elements using reduce', () => { | |
expect(sum_of_every_element([1, 2, 3])).toEqual(6) | |
}) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { reduce } from 'ramda' | |
export const sum_of_every_element = | |
reduce( | |
(previous: number, current: number) => previous + current, | |
0 | |
) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment