diff options
| author | Gaspard Coulet <gaspard.coulet@mines-ales.org> | 2021-04-28 23:05:53 +0200 |
|---|---|---|
| committer | Gaspard Coulet <gaspard.coulet@mines-ales.org> | 2021-04-28 23:05:53 +0200 |
| commit | 9fe033ea88c2f705ec18c232873d056e0c229d72 (patch) | |
| tree | 0647dc8c51610c7336c88c04de2068ea14b21e17 /sem_4/progaapp/TP1/day.rkt | |
Initial commit
Diffstat (limited to 'sem_4/progaapp/TP1/day.rkt')
| -rw-r--r-- | sem_4/progaapp/TP1/day.rkt | 103 |
1 files changed, 103 insertions, 0 deletions
diff --git a/sem_4/progaapp/TP1/day.rkt b/sem_4/progaapp/TP1/day.rkt new file mode 100644 index 0000000..c55d5f5 --- /dev/null +++ b/sem_4/progaapp/TP1/day.rkt @@ -0,0 +1,103 @@ +#lang racket +(define bissextile + (lambda (x) + ( if (= (modulo x 4) 0) + (if (not (= ( modulo x 100) 0)) + #t + (if (= ( modulo x 400) 0) + #t + #f) + ) + #f) + ) + ) + +(define nb-annee-bissextile + (lambda (x) + (letrec ( (f + (lambda (x i) + (if (not (= x 1900)) + (if (bissextile x) + (f (- x 1) (+ i 1)) + (f (- x 1) i) + ) + i) + ) + )) + ( f x 0) + ) + ) + ) + +(define nb-jours-au-1-jan + (lambda (x) + (letrec ((f + (lambda (x i) + (if (not(= x 1)) + (if (or (= 2 x) (= x 4) (= x 6) (= x 9) (= x 11)) + (if (= x 2) + (f (- x 1) ( + i 28)) + (f (- x 1) (+ i 30)) + ) + (f (- x 1) (+ i 31)) + ) + ( + i 31) + ) + ) + )) + (if (= 1 x) + 0 + ( f (- x 1) 0) + ) + ) + ) + ) + +(define nb-jours (lambda (m d y) + (let ((i (if (= y 1900) + 0 + (+ (* (nb-annee-bissextile y) 1) (* 365 (- y 1900))) + ) + )) + (let ((i (+ i (nb-jours-au-1-jan m)))) + (let ((i (+ i d))) + (- i 1) + ) + ) + ) + ) + ) + +(define jour-semaine (lambda (m d y) + (let ((nbjour (nb-jours m d y))) + (if (= (modulo nbjour 7) 0) + (display "Lundi") + (if (= (modulo nbjour 7) 1) + (display "Mardi") + (if (= (modulo nbjour 7) 2) + (display "Mercredi") + (if (= (modulo nbjour 7) 3) + (display "Jeudi") + (if (= (modulo nbjour 7) 4) + (display "Vendredi") + (if (= (modulo nbjour 7) 5) + (display "Samedi") + (if (= (modulo nbjour 7) 6) + (display "Dimanche") + (display "whut?") + ) + + ) + ) + ) + ) + ) + ) + ) + ) + ) + + + + +
\ No newline at end of file |
