 
 // Unfunctional
 
-var originalBands: Array<Dictionary<String, String>> = [
+let bands: Array<Dictionary<String, String>> = [
     ["name" : "sunset rubdown", "country" : "UK"],
     ["name" : "women", "country" : "Germany"],
     ["name" : "a silver mt. zion", "country" : "Spain"]
 ]
-var bands = originalBands // copy so we can use original data in other examples
+var bandsMutable = originalBands
 
 func formatBands(inout bands: Array<Dictionary<String, String>>) -> () {
     var newBands: Array<Dictionary<String, String>> = []

    return Int(arc4random_uniform(UInt32(number)))
}

func randomElement<T>(array: Array<T>) -> T {
    let randomIndex = randomPositiveNumberUpTo(array.count)
    return array[randomIndex]
}

let canada: BandPropertyTransform = { _ in return "Canada" };
let capitalize: BandPropertyTransform = { return $0.capitalizedString }

let setCanadaAsCountry = call(function: canada, onValueForKey: "country")
let capitalizeName = call(function: capitalize, onValueForKey: "name")

func formattedBands(bands: Array<Band>, functions: Array<BandTransform>) -> Array<Band> {
    return bands.map {
        band in
        
        functions.reduce(band) {
            (currentBand, function) in
            
            function(currentBand)
        }
    }
}

// OR shorthand:

func formattedBandsShorthand(bands: Array<Band>, functions: Array<BandTransform>) -> Array<Band> {
    return bands.map {
        functions.reduce($0) { $1($0) }
    }
}

print(bands)
print(formattedBands(bands, [setCanadaAsCountry, capitalizeName]))

// Functional 2

