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];▼
▲<syntaxhighlight lang="zig">
pub fn max(comptime T: type, input: []const T) T {
}▼
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
|