-
-
Save milanpanchal/ead0908a1950ae13f7a81299aac36a8a to your computer and use it in GitHub Desktop.
swift.swift
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
func calculateAverage(total: Int, countOfNumbers: Int) -> Int { | |
return total / countOfNumbers | |
} | |
func average(algorithm: (Int, Int) -> Int, numbers: Int...) -> Int { | |
var countOfNumbers = 0 | |
var total = 0 | |
for number in numbers { | |
total += number | |
countOfNumbers++ | |
} | |
return algorithm(total, countOfNumbers) | |
} | |
average(calculateAverage, 3, 3, 3) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment