Skip to content

Instantly share code, notes, and snippets.

@codingedgar
Last active August 30, 2018 14:52
Show Gist options
  • Save codingedgar/d68c0b11db9607694425f40172c1095a to your computer and use it in GitHub Desktop.
Save codingedgar/d68c0b11db9607694425f40172c1095a to your computer and use it in GitHub Desktop.
until transducer: reduce_sum_reduce
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)
})
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