Skip to content

Instantly share code, notes, and snippets.

@bernerdschaefer
Last active June 18, 2016 20:27
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save bernerdschaefer/dddfe6f6c30477fc492a952d1ab76952 to your computer and use it in GitHub Desktop.
Save bernerdschaefer/dddfe6f6c30477fc492a952d1ab76952 to your computer and use it in GitHub Desktop.
Leap in Kitten
// 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