I am only posting my take on the solution as part of my learning process.
This repo is also used as a milestone in my learning process where I can refine as I learn more.
To load everything use: (asdf:load-system "lectures")
or
see usage details specific to each Practical Session below.
Git clone the repo. If there are any instructions specific to particular lectures, they will appear below.
7.8 Practical session / Suggested activity.
Based on Week 7 Lecture series from Nick Levine’s lecture notes.
Activities
- [X] Create an instance of the student structure type “on the fly”. Interrogate its slot-values. Try setting them. Interrogate the slots again until comfortable.
- [X] Write a program to ask for and read in student names, and to build structures of type student (leaving the modules field blank for now). When the input is finished (you might for example let the user signal that by typing in an “empty name”; the loop macro might be useful to you so do feel free to ask about it), return the list of structures you have generated, sorted by students’ names into alphabetical order. Try to find an excuse to use lambda here.
- [X] Write a function to find the name of the student with a given SID.
- [-] Modules
- [X] Now design and define a structure for modules and
- [ ] try enrolling students onto a module.
- [ ] You can now write code to ask which modules a named student is enrolled for, or which students have enrolled for a named module.
- [ ] Marks
- [ ] Find some way of recording marks for modules which students have already attempted.
- [ ] Use reduce to find the total number of marks over all modules attempted by each student and hence the total marks obtained by the student cohort.
- [ ] Use it again to count how many modules were attempted by the cohort, and hence give the average mark.
- [ ] Name the three students who have the highest marks.
- [ ] Spot which lecturer fails most of their students.
- [ ] Answer any other questions that might be of interest.
- Load and use both the
model.lisp
andlec-7.lisp
files however you choose. The package is called:lectures-7
then either, (use-package :lectures-7)
and(main-menu)
- An onscreen menu will appear.
8.7 Practical session / Suggested activity
- [X] Hash-Table conversion
- [X] Convert 7.8 to store student records in a hash-table (accessible by name) rather than in a list.
- [X] Write functions to add a new student,
- [X] to find the record of a student with a given name,
- [X] and to delete a student.
- [ ] Marks
- [ ] As before, write functions to name the three students who have the highest marks, or to spot which lecturer fails most of their students.
- [X] Use
return-from
in a function to return the SID of any student who hasn’t attmpted any modules at all. - [ ] Comment on which data stucture was “best”. [Define “best”.]
- Jason S. Robinson
All copyright belongs to Nick Levine. This is an excellent series and I strongly recommend anyone interested to check it out.