{"id":170,"date":"2021-04-09T01:18:51","date_gmt":"2021-04-08T23:18:51","guid":{"rendered":"https:\/\/benjaminperonne.fr\/src\/wordpress\/?p=170"},"modified":"2021-04-09T03:19:27","modified_gmt":"2021-04-09T01:19:27","slug":"repertoire","status":"publish","type":"post","link":"https:\/\/benjaminperonne.fr\/src\/wordpress\/2021\/04\/09\/repertoire\/","title":{"rendered":"Repertoire"},"content":{"rendered":"\n<h3 class=\"wp-block-heading\">Introduce<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">A directory is a list of people. A person is a list containing 3 elements, a numeric identifier, a character string for the name and another for the first name.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">The resources for this project are available on my <a rel=\"noreferrer noopener\" href=\"https:\/\/github.com\/BenjaminPeronne\/Scheme_Prog_Fonct\/tree\/master\/TP\/TP_5\" data-type=\"URL\" data-id=\"https:\/\/github.com\/BenjaminPeronne\/Scheme_Prog_Fonct\/tree\/master\/TP\/TP_5\" target=\"_blank\">Github<\/a><\/p>\n\n\n\n<figure class=\"wp-block-gallery aligncenter columns-2 is-cropped wp-block-gallery-1 is-layout-flex wp-block-gallery-is-layout-flex\"><ul class=\"blocks-gallery-grid\"><li class=\"blocks-gallery-item\"><figure><img loading=\"lazy\" decoding=\"async\" width=\"689\" height=\"1024\" src=\"https:\/\/benjaminperonne.fr\/src\/wordpress\/wp-content\/uploads\/2021\/04\/Capture-decran-2021-04-08-a-21.18.17-689x1024.png\" alt=\"\" data-id=\"206\" data-full-url=\"https:\/\/benjaminperonne.fr\/src\/wordpress\/wp-content\/uploads\/2021\/04\/Capture-decran-2021-04-08-a-21.18.17.png\" data-link=\"https:\/\/benjaminperonne.fr\/src\/wordpress\/2021\/04\/09\/repertoire\/capture-decran-2021-04-08-a-21-18-17\/\" class=\"wp-image-206\" srcset=\"https:\/\/benjaminperonne.fr\/src\/wordpress\/wp-content\/uploads\/2021\/04\/Capture-decran-2021-04-08-a-21.18.17-689x1024.png 689w, https:\/\/benjaminperonne.fr\/src\/wordpress\/wp-content\/uploads\/2021\/04\/Capture-decran-2021-04-08-a-21.18.17-202x300.png 202w, https:\/\/benjaminperonne.fr\/src\/wordpress\/wp-content\/uploads\/2021\/04\/Capture-decran-2021-04-08-a-21.18.17-768x1141.png 768w, https:\/\/benjaminperonne.fr\/src\/wordpress\/wp-content\/uploads\/2021\/04\/Capture-decran-2021-04-08-a-21.18.17.png 824w\" sizes=\"auto, (max-width: 689px) 100vw, 689px\" \/><\/figure><\/li><li class=\"blocks-gallery-item\"><figure><img loading=\"lazy\" decoding=\"async\" width=\"689\" height=\"1024\" src=\"https:\/\/benjaminperonne.fr\/src\/wordpress\/wp-content\/uploads\/2021\/04\/Capture-decran-2021-04-08-a-21.18.21-689x1024.png\" alt=\"\" data-id=\"208\" data-full-url=\"https:\/\/benjaminperonne.fr\/src\/wordpress\/wp-content\/uploads\/2021\/04\/Capture-decran-2021-04-08-a-21.18.21.png\" data-link=\"https:\/\/benjaminperonne.fr\/src\/wordpress\/2021\/04\/09\/repertoire\/capture-decran-2021-04-08-a-21-18-21\/\" class=\"wp-image-208\" srcset=\"https:\/\/benjaminperonne.fr\/src\/wordpress\/wp-content\/uploads\/2021\/04\/Capture-decran-2021-04-08-a-21.18.21-689x1024.png 689w, https:\/\/benjaminperonne.fr\/src\/wordpress\/wp-content\/uploads\/2021\/04\/Capture-decran-2021-04-08-a-21.18.21-202x300.png 202w, https:\/\/benjaminperonne.fr\/src\/wordpress\/wp-content\/uploads\/2021\/04\/Capture-decran-2021-04-08-a-21.18.21-768x1141.png 768w, https:\/\/benjaminperonne.fr\/src\/wordpress\/wp-content\/uploads\/2021\/04\/Capture-decran-2021-04-08-a-21.18.21.png 824w\" sizes=\"auto, (max-width: 689px) 100vw, 689px\" \/><\/figure><\/li><\/ul><\/figure>\n\n\n\n<h3 class=\"wp-block-heading\">Main Code<\/h3>\n\n\n\n<pre class=\"wp-block-code\"><code>#lang racket\n(require racket\/gui\/base)\n\n(define repertoire '())\n\n(define (ajout-r rep nom prenom)\n  (if (null? rep) \n      (cons (list 0 nom prenom) rep) \n      (cons (list (add1 (caar rep)) nom prenom) rep)))\n\n(set!  repertoire (ajout-r repertoire \"dupond\" \"jean\"))\n(set!  repertoire (ajout-r repertoire \"dupond\" \"jacques\"))\n(set!  repertoire (ajout-r repertoire \"duval\" \"jean\"))\n(set!  repertoire (ajout-r repertoire \"dupres\" \"jacques\"))\n\nrepertoire\n\n(define (affiche-r rep)\n  (cond ((null? rep) (display \"\"))\n        (else (display (caar rep))(display \" : \") (display (cadar rep))(display \" -- \") (display (caddar rep)) (newline) (affiche-r (cdr rep)))))\n\n(affiche-r repertoire)\n\n(define (tri-ins L pred?)\n  (define (insere x L)\n    (cond ((null? L) (cons x L))\n          ((pred? x (car L)) (cons (car L) (insere x (cdr L))))\n          (else (cons x L))))\n    (if (null? L)\n        L\n        (insere (car L) (tri-ins (cdr L) pred?))))\n\n(define (compare-p p1 p2)\n  (or (string&gt;? (cadr p1) (cadr p2)) \n      (and (string=? (cadr p1) (cadr p2))\n           (string&gt;? (caddr p1) (caddr p2)))))\n\n(define (affiche-tri-r rep)\n  (affiche-r (tri-ins rep compare-p)))\n\n(set!  repertoire (ajout-r repertoire \"aa\" \"aa\"))\n(set!  repertoire (ajout-r repertoire \"aa\" \"zz\"))\n(set!  repertoire (ajout-r repertoire \"zz\" \"aa\"))\n(set!  repertoire (ajout-r repertoire \"zz\" \"zz\"))\n\n\"repertoire non tri\u00e9\"\n(affiche-r repertoire)\n\n\"repertoire tri\u00e9\"\n(affiche-tri-r repertoire)\n\n;suppression\n(define (supprime-r rep id)\n  (if (= id (caar rep))\n      (cdr rep)\n      (cons (car rep) (supprime-r (cdr rep) id))))\n\n\"suppression de 0, 7 et 3\"\n(set!  repertoire (supprime-r repertoire 0))\n(set!  repertoire (supprime-r repertoire 7))\n(set!  repertoire (supprime-r repertoire 3))\n\n\"repertoire non tri\u00e9\"\n(affiche-r repertoire)\n\n(define (extract rep lettre)\n  (cond ((null? rep) '())\n        ((eq? lettre (string-ref (cadar rep) 0)) (cons (car rep) (extract (cdr rep) lettre)))\n        (else (extract (cdr rep) lettre))))\n\n\"repertoire commence par d\"\n(define repertoire-d (extract repertoire #\\d))\n(affiche-r repertoire-d)\n\n\"repertoire commence par a\"\n(define repertoire-a (extract repertoire #\\a))\n(affiche-r repertoire-a)\n\n\"sauvegarde dans un fichier\"\n(define (save-r rep)\n  (define out (open-output-file \"repertoire.txt\" #:exists 'replace ))\n  (write rep out)\n  (close-output-port out))\n\n\"lecture dans un fichier\"\n(define (load-r)\n  (define in (open-input-file \"repertoire.txt\"))\n  (read in))\n\n(define (application)\n  (define repertoire '())\n  (define (menu)\n    (display \"0-quitter\")(newline)\n    (display \"1-afficher\")(newline)\n    (display \"2-ajouter\")(newline)\n    (display \"3-sauver\")(newline)\n    (display \"4-charger\")(newline)\n    (display \"...\")(newline)\n    (let ((choix (read)))\n      (cond ((eq? choix 0) (display \"bye \\n\"))\n            ((eq? choix 1) (affiche-r repertoire) (menu))\n            ((eq? choix 2) (set! repertoire (ajout-r repertoire (read) (read))) (menu))\n            (else (display \" pas encore impl\u00e9ment\u00e9\\n\") (menu)))))\n    (menu))\n\n;Interface graphique\n(define $repertoire\n  (new frame% &#91;label \"Repertoire\"]&#91;parent #f]&#91;width 300]&#91;height 500]))\n(define $panel-v (new vertical-panel% &#91;parent $repertoire]))\n(define $panel-h (new horizontal-panel% &#91;parent $panel-v]))\n\n;\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/Affiche r\u00e9pertoire\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\n(define (aff-rep rep)\n  (let (($panel-ho (new horizontal-panel% &#91;parent $panel-v])))\n    (send $panel-ho set-alignment 'left 'top)\n  (define $bouton-supp\n  (new button% &#91;label \"delete\"] &#91;parent $panel-ho]\n       &#91;callback\n        (lambda (b e)\n          (supp (car rep))\n          (affiche-r repertoire)\n          (delete))\n        ]\n       ))\n  (cond ((null? rep) '())\n        ((null? (cdr rep)) (send $bouton-supp show #t)(new message% &#91;label (string-append (number-&gt;string (caar rep)) \" \" (cadar rep) \" \" (caddar rep) \"\\n\")] &#91;parent $panel-ho]))\n        (else (send $bouton-supp show #t)(new message% &#91;label (string-append (number-&gt;string (caar rep)) \" \" (cadar rep) \" \" (caddar rep) \"\\n\")] &#91;parent $panel-ho])(aff-rep (cdr rep))))))\n        \n\n;\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/BOUTTON AJOUT\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\n(define $nom \"le nom avant\")\n(define $pnom \"le pr\u00e9nom apr\u00e8s\")\n\n(define $dialog\n  (new dialog% &#91;label \"Ajoutation\"]&#91;parent $repertoire]&#91;width 200]&#91;height 100]))\n\n(define $texte-n\n  (new text-field% &#91;label \"Votre Nom :\"]&#91;parent $dialog]&#91;init-value \"NOM\"]))\n(define $texte-p\n  (new text-field% &#91;label \"Votre Prenom :\"]&#91;parent $dialog]&#91;init-value \"PRENOM\"]))\n\n(define $panel2 (new horizontal-panel% &#91;parent $dialog]))\n(send $panel2 set-alignment 'center 'center)\n(define $bouton-ok\n  (new button% &#91;label \"ok\"]&#91;parent $panel2]\n       &#91;callback\n        (lambda (b e)\n          (let ((nom (send $texte-n get-value)) (pnom (send $texte-p get-value)))\n            (set! $nom nom)\n            (set! $pnom pnom)\n            (set!  repertoire (ajout-r repertoire nom pnom))\n            (send $dialog show #f)\n            (delete)))\n        ]\n       ))\n\n(define $bouton-cancel\n  (new button% &#91;label \"annuler\"]&#91;parent $panel2]\n       &#91;callback\n        (lambda (b e)\n          (send $dialog show #f))\n        ]\n       ))\n;\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\n;\/\/\/\/\/\/\/\/\/\/\/\/\/BOUTTON AJOUT\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\n(define $bouton-ajout\n  (new button% &#91;label \"ajouter\"] &#91;parent $repertoire]\n       &#91;callback\n        (lambda (b e)\n          (send $dialog show #t))\n        ]\n       ))\n;\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\n\n;\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/SUPPP\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\n(define (supp rep)\n  (set!  repertoire (supprime-r repertoire (car rep))))\n;\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\n\n\n;\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/DELETE\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\n(define (delete)\n  (define (delete1)\n    (send $panel-v delete-child (car (send $panel-v get-children)))(delete))\n  (cond ((not (null? (send $panel-v get-children))) (delete1))\n        (else (aff-rep repertoire))))\n;\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\n\n(aff-rep repertoire)\n\n\n(define (go)\n  (send $repertoire show #t))\n(go)<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\">Video<\/h3>\n\n\n\n<figure class=\"wp-block-video aligncenter\"><video height=\"2100\" style=\"aspect-ratio: 3360 \/ 2100;\" width=\"3360\" controls loop muted src=\"https:\/\/benjaminperonne.fr\/src\/wordpress\/wp-content\/uploads\/2021\/04\/remove.mov\" playsinline><\/video><figcaption><strong>Fonction Remove<\/strong><\/figcaption><\/figure>\n\n\n\n<hr class=\"wp-block-separator\"\/>\n\n\n\n<figure class=\"wp-block-video aligncenter\"><video height=\"2100\" style=\"aspect-ratio: 3360 \/ 2100;\" width=\"3360\" controls loop muted src=\"https:\/\/benjaminperonne.fr\/src\/wordpress\/wp-content\/uploads\/2021\/04\/Ajout.mov\" playsinline><\/video><figcaption><strong>Fonction d&#8217;ajout<\/strong><\/figcaption><\/figure>\n","protected":false},"excerpt":{"rendered":"<p>Introduce A directory is a list of people. A person is a list containing 3 elements, a numeric identifier, a character string for the name and another for the first name. The resources for this project are available on my Github Main Code Video<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_monsterinsights_skip_tracking":false,"_monsterinsights_sitenote_active":false,"_monsterinsights_sitenote_note":"","_monsterinsights_sitenote_category":0,"footnotes":""},"categories":[6],"tags":[],"class_list":["post-170","post","type-post","status-publish","format-standard","hentry","category-scheme"],"_links":{"self":[{"href":"https:\/\/benjaminperonne.fr\/src\/wordpress\/wp-json\/wp\/v2\/posts\/170","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/benjaminperonne.fr\/src\/wordpress\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/benjaminperonne.fr\/src\/wordpress\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/benjaminperonne.fr\/src\/wordpress\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/benjaminperonne.fr\/src\/wordpress\/wp-json\/wp\/v2\/comments?post=170"}],"version-history":[{"count":12,"href":"https:\/\/benjaminperonne.fr\/src\/wordpress\/wp-json\/wp\/v2\/posts\/170\/revisions"}],"predecessor-version":[{"id":211,"href":"https:\/\/benjaminperonne.fr\/src\/wordpress\/wp-json\/wp\/v2\/posts\/170\/revisions\/211"}],"wp:attachment":[{"href":"https:\/\/benjaminperonne.fr\/src\/wordpress\/wp-json\/wp\/v2\/media?parent=170"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/benjaminperonne.fr\/src\/wordpress\/wp-json\/wp\/v2\/categories?post=170"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/benjaminperonne.fr\/src\/wordpress\/wp-json\/wp\/v2\/tags?post=170"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}