Skip to content
GitLab
Explorer
Connexion
S'inscrire
Navigation principale
Rechercher ou aller à…
Projet
L
LINFO2335 - Assignement Project 2
Gestion
Activité
Membres
Labels
Programmation
Tickets
Tableaux des tickets
Jalons
Wiki
Code
Requêtes de fusion
Dépôt
Branches
Validations
Étiquettes
Graphe du dépôt
Comparer les révisions
Extraits de code
Compilation
Pipelines
Jobs
Planifications de pipeline
Artéfacts
Déploiement
Releases
Registre de paquets
Registre de conteneur
Registre de modèles
Opération
Environnements
Modules Terraform
Surveillance
Incidents
Analyse
Données d'analyse des chaînes de valeur
Analyse des contributeurs
Données d'analyse CI/CD
Données d'analyse du dépôt
Expériences du modèle
Aide
Aide
Support
Documentation de GitLab
Comparer les forfaits GitLab
Forum de la communauté
Contribuer à GitLab
Donner votre avis
Conditions générales et politique de confidentialité
Raccourcis clavier
?
Extraits de code
Groupes
Projets
Afficher davantage de fils d'Ariane
Nicolas Verbois
LINFO2335 - Assignement Project 2
Validations
2935d53d
Valider
2935d53d
rédigé
3 years ago
par
Nicolas Verbois
Parcourir les fichiers
Options
Téléchargements
Correctifs
Plain Diff
Update step_0.rkt : adding comments and more tests
parent
8e4dd9f2
Aucune branche associée trouvée
Aucune étiquette associée trouvée
Aucune requête de fusion associée trouvée
Modifications
1
Masquer les modifications d'espaces
En ligne
Côte à côte
Affichage de
1 fichier modifié
step_0.rkt
+48
-4
48 ajouts, 4 suppressions
step_0.rkt
avec
48 ajouts
et
4 suppressions
step_0.rkt
+
48
−
4
Voir le fichier @
2935d53d
#
lang
r5rs
; Authors : Nicolas Verbois - 1366 1600
; Nicolas Rosar - 1443 1900
; Group F
; This acts as the first step in building objects in Scheme
; The object, here a point, is defined as a dispacther returning values.
; We thus emulate a point class as a constructor function that creates
; an object through a dispacter function.
; A point will be defined as an object containing two coordinates, x and y.
; Once the object is created using the constructor, the dispacther will be
; able to respond to messages, concerning those two coordinates as well as
; characteristics of the point object, like the type of object, or printing
; a "string-like" representation using the "info" message.
; In case of a message that the dispatcher cannot handle, it will return a
; simple error message through a display.
(
define
(
point
x
y
)
(
define
(
dispatch
m
)
...
...
@@ -9,11 +26,38 @@
(
else
(
display
"ERROR"
))))
dispatch
)
; Sample code illustrating the execution of the step
; We start by trying to create a new point p
(
define
p
(
point
1
2
))
(
display
(
p
'getx
))
(
display
(
p
'getx
))
; should display : 1
(
newline
)
(
display
(
p
'gety
))
(
display
(
p
'gety
))
; should display : 2
(
newline
)
(
display
(
p
'type
))
(
display
(
p
'type
))
; should display : point
(
newline
)
(
display
(
p
'info
))
; should display : (point 1 2)
(
newline
)
(
display
(
p
'info
))
(
display
'------------
)
(
newline
)
; We then create a second point p
(
define
p2
(
point
4
-1
))
(
display
(
p2
'getx
))
; should display : 4
(
newline
)
(
display
(
p2
'gety
))
; should display : -1
(
newline
)
(
display
(
p2
'type
))
; should display : point
(
newline
)
(
display
(
p2
'info
))
; should display : (point 4 -1)
Ce diff est replié.
Cliquez pour l'agrandir.
Aperçu
0%
Chargement en cours
Veuillez réessayer
ou
joindre un nouveau fichier
.
Annuler
You are about to add
0
people
to the discussion. Proceed with caution.
Terminez d'abord l'édition de ce message.
Enregistrer le commentaire
Annuler
Veuillez vous
inscrire
ou vous
se connecter
pour commenter