September 2017 Update

This commit is contained in:
Ingy döt Net 2017-09-23 10:01:46 +02:00
parent bba7bfd280
commit ba8067c3b7
14570 changed files with 153136 additions and 63871 deletions

View file

@ -0,0 +1,16 @@
begin
% returns true if year is a leap year, false otherwise %
% assumes year is in the Gregorian Calendar %
logical procedure isLeapYear ( integer value year ) ;
year rem 400 = 0 or ( year rem 4 = 0 and year rem 100 not = 0 );
% some test cases %
for year := 1899, 1900, 1901, 1902, 1903, 1904, 1905, 1999, 2000, 2001, 2002, 2003, 2004 do begin
write( i_w := 1, s_w := 0
, year
, " is "
, if isLeapYear( year ) then "" else "not "
, " a leap year"
)
end for_year
end.

View file

@ -0,0 +1,4 @@
⍝returns 1 if leapyear, 0 otherwise:
ZLEAPYEAR YEAR
Z(0=4|YEAR)(0=400|YEAR)~0=100|YEAR

View file

@ -0,0 +1,2 @@
5000 LET L=Y/4=INT (Y/4) AND (Y/100<>INT (Y/100) OR Y/400=INT (Y/400))
5010 RETURN

View file

@ -0,0 +1,6 @@
10 INPUT Y
20 GOSUB 5000
30 PRINT Y;" IS ";
40 IF NOT L THEN PRINT "NOT ";
50 PRINT "A LEAP YEAR."
60 STOP

View file

@ -0,0 +1 @@
10 DEF FN l(y)=y/4=INT (y/4) AND y/100<>INT (y/100) OR y/400=INT (y/400)

View file

@ -0,0 +1,12 @@
' Leap year
FUNCTION leapyear(NUMBER y) TYPE NUMBER
RETURN IIF(MOD(y, 4) = 0, IIF(MOD(y, 16) = 0, IIF(MOD(y, 100) != 0, TRUE, FALSE), TRUE), FALSE)
END FUNCTION
READ y
WHILE y != 0
PRINT y, ": ", IIF$(leapyear(y), "", "not a "), "leapyear"
READ y
WEND
DATA 1600, 1700, 1800, 1900, 1901, 1996, 2000, 2001, 2004, 0

View file

@ -1 +0,0 @@
=IF(OR(NOT(MOD(A1;400));AND(NOT(MOD(A1;4));MOD(A1;100)));"Leap Year";"Not a Leap Year")

View file

@ -1,5 +0,0 @@
1900 Not a Leap Year
1954 Not a Leap Year
1996 Leap Year
2003 Not a Leap Year
2012 Leap Year

View file

@ -0,0 +1,11 @@
Public Sub Form_Open()
Dim dDate As Date
Dim siYear As Short = InputBox("Enter a year", "Leap year test")
Dim sMessage As String = " is a leap year."
Try dDate = Date(siYear, 02, 29)
If Error Then sMessage = " is not a leap year."
Message(siYear & sMessage)
End

View file

@ -1 +0,0 @@
new java.util.GregorianCalendar().isLeapYear(year)

View file

@ -1,5 +0,0 @@
public static boolean isLeapYear(int year){
if(year % 100 == 0)
return year % 400 == 0;
return year % 4 == 0;
}

View file

@ -0,0 +1,4 @@
::routine isLeapYear
use arg year
d = .datetime~new(year, 1, 1)
return d~isLeapYear

View file

@ -1,4 +0,0 @@
require 'date'
def leap_year?(year)
Date.new(year).leap?
end

View file

@ -1,3 +0,0 @@
[2000, 1900, 1800, 1700, 1600, 1500, 1400].each do |year|
print year, (leap_year? year) ? " is" : " is not", " a leap year.\n"
end

View file

@ -1,4 +0,0 @@
require 'date'
def leap_year?(year)
Date.new(year, 1, 1, Date::GREGORIAN).leap?
end

View file

@ -0,0 +1 @@
gen leap = mod(year,400)==0 | mod(year,4)==0 & mod(year,100)!=0

View file

@ -2,5 +2,5 @@ func isLeapYear(year:Int) -> Bool {
return (year % 100 == 0) ? (year % 400 == 0) : (year % 4 == 0)
}
println(isLeapYear(2000))
println(isLeapYear(2011))
print(isLeapYear(2000))
print(isLeapYear(2011))

View file

@ -0,0 +1,3 @@
Time.Date.isLeapYear(1988) //-->True
T(1988,1989,1900,2000).apply(Time.Date.isLeapYear)
//-->L(True,False,False,True)