mapReduce complexity

mapReduce invokes both 'map' and 'reduce', for a complexity of O(2n)
This commit changes mapReduce to avoid calling map and reduce, making it O(n).
Merge pull request #1 from mattjmattj/mapreduce-complexity

Reduced mapReduce() complexity