Created
December 11, 2014 09:48
-
-
Save volgar1x/a3b620084f66a63621bb to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| (defun rac (arbre) | |
| (car arbre)) | |
| (defun sag (arbre) | |
| (car (cdr arbre))) | |
| (defun sad (arbre) | |
| (car (cdr (cdr arbre)))) | |
| (defun plus-grand (a b) | |
| ;(> a b)) | |
| (string> (symbol-name (car a)) | |
| (symbol-name (car b)))) | |
| (defun plus-petit (a b) | |
| ;(< a b)) | |
| (string< (symbol-name (car a)) | |
| (symbol-name (car b)))) | |
| (defun etu-moyenne (a b) | |
| (destructuring-bind ((nom aa) (_ bb)) (list a b) | |
| (list nom (floor (+ aa bb) 2)))) | |
| (defun etu-inc (etu) | |
| (destructuring-bind (nom cur) etu | |
| (list nom (+ cur 1)))) | |
| (defun etu-zero (etu) | |
| (list (car etu) 0)) | |
| (defun update-rac (arbre new-rac) | |
| (let ((left (sag arbre)) | |
| (right (sad arbre))) | |
| (list new-rac left right))) | |
| (defun add (elem arbre) | |
| (cond | |
| ; we reached the upper leafs of the tree | |
| ((null arbre) | |
| (list (etu-inc (etu-zero elem)) nil nil)) | |
| ; we can sort out the elem | |
| ((plus-grand elem (rac arbre)) | |
| (list (rac arbre) | |
| (sag arbre) | |
| (add elem (sad arbre)))) | |
| ((plus-petit elem (rac arbre)) | |
| (list (rac arbre) | |
| (add elem (sag arbre)) | |
| (sad arbre))) | |
| ; we found collisions | |
| (t | |
| ; compute student's mean mark | |
| ; (update-rac arbre (etu-moyenne elem (rac arbre)))))) | |
| ; compute student's number of marks | |
| (update-rac arbre (etu-inc (rac arbre)))))) | |
| (defun ajout (elems arbre) | |
| (cond | |
| ((null elems) | |
| arbre) | |
| (t | |
| (ajout (cdr elems) (add (car elems) arbre))))) | |
| (defun parcours (arbre) | |
| (cond | |
| ((null arbre) | |
| nil) | |
| (t | |
| (append (parcours (sag arbre)) | |
| (list (rac arbre)) | |
| (parcours (sad arbre)))))) | |
| (defun recherchep (elem arbre) | |
| (cond | |
| ((null arbre) | |
| nil) | |
| ((plus-grand elem (rac arbre)) | |
| (recherchep elem (sad arbre))) | |
| ((plus-petit elem (rac arbre)) | |
| (recherchep elem (sag arbre))) | |
| (t | |
| t))) | |
| (defun egaliteABR (left right) | |
| (equal (parcours left) (parcours right))) | |
| (defun liste-notes () | |
| '((E1 2) (E3 4) (E3 9) (E3 8) (E2 17) (E4 16) (E3 14) (E1 15) (E3 19) (E3 4) | |
| (E4 11) (E0 5) (E1 4) (E4 4) (E1 20) (E3 18) (E1 0) (E2 1) (E0 7) (E0 6) | |
| (E2 15) (E2 4) (E1 6) (E0 13) (E1 11) (E1 16) (E3 16) (E2 5) (E4 11) (E4 17) | |
| (E1 11) (E1 4) (E3 9) (E2 9) (E3 3) (E3 12) (E2 14) (E3 0) (E0 20) (E3 6) | |
| (E0 6) (E0 17) (E4 11) (E3 16) (E3 19) (E4 16) (E4 9) (E3 9) (E2 12) (E0 19) | |
| (E2 17) (E0 18) (E1 20) (E3 7) (E2 2) (E1 5) (E2 17) (E3 18) (E1 4) (E1 11) | |
| (E2 2) (E4 17) (E0 11) (E1 0) (E3 15) (E4 6) (E0 2) (E3 6) (E3 13) (E3 1) | |
| (E3 18) (E2 1) (E3 12) (E0 11) (E0 1) (E1 12) (E1 5) (E4 5) (E4 6) (E3 20) | |
| (E0 16) (E3 15) (E2 10) (E2 1) (E2 4) (E3 11) (E1 4) (E0 9) (E4 18) (E3 14) | |
| (E1 0) (E0 7) (E4 12) (E0 5) (E4 11) (E4 19) (E3 3) (E4 11) (E2 0) (E2 14))) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment