Jump to content

Greatest element of a list: Difference between revisions

no edit summary
No edit summary
Line 4,466:
<pre>ListMaxTest
Greatest element is 5992424433449</pre>
 
=={{header|Vlang}}==
<lang vlang>fn max<T>(list []T) T {
mut max := list[0]
for i in 1..list.len {
if list[i] > max {
max = list[i]
}
}
return max
}
fn main() {
println('int max: ${max<int>([5,6,4,2,8,3,0,2])}')
println('float max: ${max<f64>([1e4, 1e5, 1e2, 1e9])}')
}</lang>
{{out}}
<pre>int max: 8
float max: 1e9</pre>
 
=={{header|Wart}}==
338

edits

Cookies help us deliver our services. By using our services, you agree to our use of cookies.