reduce in python
'''try this'''
from functools import reduce
a = [1,2,3,4]
SUM = reduce(lambda n,n2:n+n2,a)
print(SUM)
reduce in python
'''try this'''
from functools import reduce
a = [1,2,3,4]
SUM = reduce(lambda n,n2:n+n2,a)
print(SUM)
reduce()
const array1 = [1, 2, 3, 4];
const reducer = (accumulator, currentValue) => accumulator + currentValue;
// 1 + 2 + 3 + 4
console.log(array1.reduce(reducer));
// expected output: 10
// 5 + 1 + 2 + 3 + 4
console.log(array1.reduce(reducer, 5));
// expected output: 15
syntax of reduce in js
[1,2,3,4,5].reduce((acc, current)=>acc+current, 0)
Copyright © 2021 Codeinu
Forgot your account's password or having trouble logging into your Account? Don't worry, we'll help you to get back your account. Enter your email address and we'll send you a recovery link to reset your password. If you are experiencing problems resetting your password contact us