# reduce(f)
# After performing the specified commutative and associative binary operation, the element in the RDD is returned. 
from pyspark import SparkContext
from operator import add
sc = SparkContext("local", "Reduce app")
nums = sc.parallelize([1, 2, 3, 4, 5])
adding = nums.reduce(add)
print "Adding all the elements -> %i" % (adding)
# reduce(f)
# After performing the specified commutative and associative binary operation, the element in the RDD is returned. 
from pyspark import SparkContext
from operator import add
sc = SparkContext("local", "Reduce app")
nums = sc.parallelize([1, 2, 3, 4, 5])
adding = nums.reduce(add)
print "Adding all the elements -> %i" % (adding)
# reduce(f) # After performing the specified commutative and associative binary operation, the element in the RDD is returned.