 
     func map<T>(_ transform: @escaping (Element) -> T) -> MappedGenerator<Self, T> {
         return MappedGenerator(base: self, transformer: transform)
+    }
+
+    mutating func reduce<T>(initial: T, _ reducer: (T, Element) -> T) -> T {
+        var result = initial
+        self.forEach { (item) in
+            result = reducer(result, item)
+        }
+        return result
     }
 
     func filter(_ shouldInclude: @escaping (Element) -> Bool) -> FilteredGenerator<Self> {

    mutating func next() -> Element?

    mutating func forEach(_ body: (Element) -> Void)
    func map<T>(_ transform: @escaping (Element) -> T) -> MappedGenerator<Self, T>
    func filter(_ shouldInclude: @escaping (Element) -> Bool) -> FilteredGenerator<Self>
    func enumerated() -> EnumeratedGenerator<Self>


 and much of the Swift standard library is built with generic code.
 
 */

import Foundation

/*:
 
 We all know that the following code is redundant and not easy to maintain.
