;------------------------------------------------------------------ ; vendredi 5 mars 2007. ; ; Fichier MAP modulo 3 ; MAP identique a celle prise en exemple pour didapage ; mais toutes les valeurs sont tirees au sort ; Ecrit en Le_Lisp 1.76.1 ; pour lancer le programme principal taper (boucle) et return ;------------------------------------------------------------------ (de r () (random 0 3)))) (de initialisation_MAP () (setq compteur 0) (lmargin 10) (terpri) (print '(**********************************************************)) (print " INITALISATION DE LA MAP") (terpri) (setq tab_coeff_poly (list (list (r)(r)(r))(list (r)(r)(r))(list (r)(r)(r)) (list (r)(r)(r))(list (r)(r)(r))(list (r)(r)(r)) (list (r)(r)(r))(list (r)(r)(r))(list (r)(r)(r)) )) (print "table des coefficients des polynomes") (print "colonne 0 1 2 3 4 5 6 7 8") (print_tab_coeff_poly) (terpri) (setq a_boite_externe (r) b_boite_externe (r) c_boite_externe (r)) (print "a_boite_externe = " a_boite_externe) (print "b_boite_externe = " b_boite_externe) (print "c_boite_externe = " c_boite_externe) (terpri) (setq entree_t_1 (r) sortie_t_1 (r)) (print "entree_t_1 = " entree_t_1) (print "sortie_t_1 = " sortie_t_1) (terpri) )))))) ;fonction d'affichage un peu compliquee parce que la fonction d'affichage ;habituelle 'print (mapcar tab_coeff_poly) aurait affiche la transposee (de print_tab_coeff_poly () (lmargin 20) (terpri) (print (nth 0 (nth 0 tab_coeff_poly))" "(nth 0 (nth 1 tab_coeff_poly))" "(nth 0 (nth 2 tab_coeff_poly))" " (nth 0 (nth 3 tab_coeff_poly))" "(nth 0 (nth 4 tab_coeff_poly))" "(nth 0 (nth 5 tab_coeff_poly))" " (nth 0 (nth 6 tab_coeff_poly))" "(nth 0 (nth 7 tab_coeff_poly))" "(nth 0 (nth 8 tab_coeff_poly))) (print (nth 1 (nth 0 tab_coeff_poly))" "(nth 1 (nth 1 tab_coeff_poly))" "(nth 1 (nth 2 tab_coeff_poly))" " (nth 1 (nth 3 tab_coeff_poly))" "(nth 1 (nth 4 tab_coeff_poly))" "(nth 1 (nth 5 tab_coeff_poly))" " (nth 1 (nth 6 tab_coeff_poly))" "(nth 1 (nth 7 tab_coeff_poly))" "(nth 1 (nth 8 tab_coeff_poly))) (print (nth 2 (nth 0 tab_coeff_poly))" "(nth 2 (nth 1 tab_coeff_poly))" "(nth 2 (nth 2 tab_coeff_poly))" " (nth 2 (nth 3 tab_coeff_poly))" "(nth 2 (nth 4 tab_coeff_poly))" "(nth 2 (nth 5 tab_coeff_poly))" " (nth 2 (nth 6 tab_coeff_poly))" "(nth 2 (nth 7 tab_coeff_poly))" "(nth 2 (nth 8 tab_coeff_poly))) (lmargin 10)))))) (de boite_externe (entree) (setq sortie (rem (+ (* a_boite_externe entree entree) (* b_boite_externe entree) c_boite_externe) 3))))))) (de fait_colonne (entree sortie) (+ (* entree 3) sortie))))))))) (de polynome (entree colonne) (setq coeff (nth colonne tab_coeff_poly)) (setq coeff_a (nth 0 coeff)) (setq coeff_b (nth 1 coeff)) (setq coeff_c (nth 2 coeff)) (setq polynome (rem (+ (* coeff_a entree entree)(* coeff_b entree) coeff_c) 3)))))))) (de calcul_point_suivant_map () (print '(************************************************************)) (print " CALCUL DU POINT SUIVANT DE LA TRAJECTOIRE DE LA MAP") (lmargin 10) (terpri) (print "point " compteur " de la trajectoire.") (terpri) (print "table des coefficients des polynomes") (print "colonne 0 1 2 3 4 5 6 7 8") (print_tab_coeff_poly) (terpri) (print "entree_t_1 = " entree_t_1) (print "sortie_t_1 = " sortie_t_1) (setq entree_t (boite_externe sortie_t_1)) (setq colonne_t (fait_colonne entree_t_1 sortie_t_1)) (print "colonne_t = " colonne_t) (terpri) (setq sortie_t (polynome entree_t colonne_t)) (setq colonne_t+1 (fait_colonne entree_t sortie_t)) (print "entree_t = " entree_t) (print "sortie_t = " sortie_t) (print "colonne_t+1 = " colonne_t+1) (terpri) ;modification de la table des coeffficients des polynomes (setq a_t (nth 0 (nth colonne_t tab_coeff_poly))) (setq b_t (nth 1 (nth colonne_t tab_coeff_poly))) (setq c_t (nth 2 (nth colonne_t tab_coeff_poly))) (setq a_t+1 (nth 0 (nth colonne_t+1 tab_coeff_poly))) (setq b_t+1 (nth 1 (nth colonne_t+1 tab_coeff_poly))) (setq c_t+1 (nth 2 (nth colonne_t+1 tab_coeff_poly))) (setq a_t (rem (+ a_t a_t+1) 3)) (setq b_t (rem (+ b_t b_t+1) 3)) (setq c_t (rem (+ c_t c_t+1) 3)) (setq nouveaux_coeff_colonne_t (list a_t b_t c_t)) (setq tab_coeff_poly (subst colonne_t nouveaux_coeff_colonne_t tab_coeff_poly)) (print "table modifiee des coefficients des polynomes") (print "la colonne " colonne_t " a ete modifiee.") (terpri) (print "colonne 0 1 2 3 4 5 6 7 8") (print_tab_coeff_poly) (terpri) (setq compteur (+ 1 compteur)) ;report des valeurs d'entree sortie de la MAP pour le point suivant (setq entree_t_1 entree_t sortie_t_1 sortie_t)) )))))))))))))))))))) ;la fonction qui effectue des substitutions dans les listes ;pour modifier tab_coeff_poly (de SUBST (n-ieme n-element tape) (setq n-l 0 recoit-l nil ) (while (<> n-l n-ieme) (setq recoit-l (cons (car tape) recoit-l) tape (cdr tape) n-l (1+ n-l))) (setq tape (cdr tape)) (setq tape (cons n-element tape)) (while recoit-l (setq tape (cons (car recoit-l) tape ) recoit-l (cdr recoit-l))) tape)) (de boucle () (setq lecture 'A) (initialisation_MAP) (terpri) (print "taper n'importe quelle touche sauf n pour continuer") (setq lecture (read)) (while (neq lecture 'N) (calcul_point_suivant_MAP) (terpri) (print "taper n'importe quelle touche sauf n pour continuer") (setq lecture (read))) (print "on est sortie de la boucle") )))))))))))))