swift-for-python-programmers

Sum of elements of an array

🏡
func simpleArraySum(ar: [Int]) -> Int {
    var cnt: Int = 0

    for i in 0...ar.count-1 {
        cnt = cnt + ar[i]
    }
    
    return cnt

}