;Gaspard Coulet, 21601609 Groupe B #lang racket (define exo9 (lambda (t) (if (and ( >= t -3) (<= t -1)) 1 (if (and (>= t 2) (<= t 4)) 2 0)))) (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 "étrange") ) ) ) ) ) ) ) ) ) ) ;Question devoir TP1 : ; Exercice 1 : ; (map exo9 '(-5 -4 -3 -2 -1 0 1 2 3 4 5)) ; Exercice 2 : ; (bissextile 1408) ; (bissextile 1500) ; (jour-semaine 1 13 2408)