fork(2) download
  1. ; tomohiko sakamoto's day-of-week algorithm
  2.  
  3. (define (day-of-week year month day)
  4. (let ((t '#(0 3 2 5 0 3 5 1 4 6 2 4))
  5. (year (if (< month 3) (- year 1) year)))
  6. (vector-ref '#(Sun Mon Tue Wed Thu Fri Sat)
  7. (modulo (+ year (quotient year 4)
  8. (- (quotient year 100)) (quotient year 400)
  9. (vector-ref t (- month 1)) day) 7))))
  10.  
  11. (display (day-of-week 2016 2 28)) (newline)
  12. (display (day-of-week 2016 2 29)) (newline)
  13. (display (day-of-week 2016 3 1)) (newline)
  14. (display (day-of-week 2016 6 17)) (newline)
Success #stdin #stdout 0.04s 8616KB
stdin
Standard input is empty
stdout
Sun
Mon
Tue
Fri