Skip to content

Instantly share code, notes, and snippets.

@keremvatandas
Created February 16, 2019 12:51
Show Gist options
  • Save keremvatandas/0e95793748617a8b39f737f3a17359bb to your computer and use it in GitHub Desktop.
Save keremvatandas/0e95793748617a8b39f737f3a17359bb to your computer and use it in GitHub Desktop.
func getMax<T: Comparable>(dizi a: [T]) -> T
{
var max = a[0]
for i in 1..<a.count {
if max < a[i] {
max = a[i]
}
}
return max
}
let sayiDizisi = [97, 34, 1, 129, 444]
getMax(dizi: sayiDizisi) // 444
let sayiDizisi2 = [97.0, 97.12, 1, 97.88, 97.9]
getMax(dizi: sayiDizisi2) // 97.90000000000001
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment