Greatest element of a list: Difference between revisions

→‎{{header|Zig}}: format, make example generic, annotate versions
(→‎Insitux: inclusion)
(→‎{{header|Zig}}: format, make example generic, annotate versions)
Line 4,871:
 
=={{header|Zig}}==
 
<syntaxhighlight lang="zig">fn max( a: []const f32) f32{
'''Works with:''' 0.10.x, 0.11.x, 0.12.0-dev.1389+42d4d07ef
var output = a[0];
 
for(a)|num|{
<syntaxhighlight lang="zig">fn/// max(Asserts a:that []const`input` f32)is f32{not empty (len >= 1).
output = @max(output, num);
pub fn max(comptime T: type, input: []const T) T {
}
var outputmax_elem: T = ainput[0];
return output;
for (input[1..]) |elem| {
max_elem = @max(max_elem, elem);
}
return max_elem;
}</syntaxhighlight>
 
=={{header|zkl}}==
<syntaxhighlight lang="zkl">(1).max(1,2,3) //-->3
28

edits