Leap year: Difference between revisions

Content added Content deleted
(add simple POSIX shell implementation)
(added Zig)
Line 3,672: Line 3,672:
> is_leap([1988,1989,1900,2000])
> is_leap([1988,1989,1900,2000])
[1,0,0,1]</pre>
[1,0,0,1]</pre>

=={{header|Zig}}==
<syntaxhighlight lang="Zig">pub fn isLeapYear(year: anytype) bool {
const inttype = @TypeOf(year);
if (@typeInfo(inttype) != .Int) {
@compileError("non-integer type used on leap year: " ++ @typeName(inttype));
}
return (if (@mod(year, @as(inttype, 100)) == 0)
@mod(year, @as(inttype, 400)) == 0
else
@mod(year, @as(inttype, 4)) == 0);
}</syntaxhighlight>


=={{header|zkl}}==
=={{header|zkl}}==