Last active
June 18, 2016 20:27
-
-
Save bernerdschaefer/dddfe6f6c30477fc492a952d1ab76952 to your computer and use it in GitHub Desktop.
Leap in Kitten
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// The exercism "Leap" program in Kitten | |
// http://exercism.io/exercises/ruby/leap/readme | |
// http://kittenlang.org/ | |
1996 isLeapYear "1996 is a leap year" assert | |
1997 isLeapYear "1997 is not a leap year" refute | |
1998 isLeapYear "1998 is not a leap year" refute | |
1900 isLeapYear "1900 is not a leap year" refute | |
1800 isLeapYear "1800 is not a leap year" refute | |
2400 isLeapYear "2400 is a leap year" assert | |
2000 isLeapYear "2000 is a leap year" assert | |
define isLeapYear (int -> bool): | |
-> x; | |
x isQuadrennial && (x isCentennial) not || x isQuadricentennial | |
define isQuadrennial (int -> bool): 4 isDivisibleBy | |
define isCentennial (int -> bool): 100 isDivisibleBy | |
define isQuadricentennial (int -> bool): 400 isDivisibleBy | |
define isDivisibleBy (int int -> bool): (%) 0 (=) | |
define assert (bool [char] ->): | |
-> got message; | |
if ( got not ): | |
message say | |
define refute (bool [char] ->): | |
swap not swap assert |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment