Jump to content

Leap year: Difference between revisions

No edit summary
Line 3,819:
 
defn main(year):
say: "$year is $(when-not leap-year(year) 'not ')a leap year."
say: |
Is $year a leap year?
 
# Either one works:
Answer: $leap-year(year)
 
defn leap-year(year):
((year % 4) == 0) && (((year % 100) > 0) || ((year % 100) == 0))
if:
 
and:
defn zero?: leap-year(year % 4):
orand:
poszero?: (year % 1004)
if or:
zero?: (year % 400)
=> pos?: "Yes"(year % 100)
=> zero?: "No"(year % 400)
</syntaxhighlight>
 
55

edits

Cookies help us deliver our services. By using our services, you agree to our use of cookies.