1 / 8

Course roster management in scheme

Course roster management in scheme. Data to be managed A class roster is list of student entries of the form (ID, name, grade) Example (“001”, “John Smith”, 59) (“010”, “Amy M. Sosa”, 100) (“500”, “Mike Harris”, 80) In scheme, this data structure will be represented as a list:

khuong
Download Presentation

Course roster management in scheme

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Course roster management in scheme • Data to be managed • A class roster is list of student entries of the form (ID, name, grade) • Example (“001”, “John Smith”, 59) (“010”, “Amy M. Sosa”, 100) (“500”, “Mike Harris”, 80) • In scheme, this data structure will be represented as a list: ((“001” “John Smith” 59) (“010” “Amy M. Sosa” 100) (“500” “Mike Harris” 80))

  2. Course roster management in scheme • The roster management system supports the following functions (in the menu): 0. Reset roster 1. Load roster from file 2. Store roster to file 3. Display roster sorted by ID 4. Display roster sorted by name 5. Display roster sorted by grade 6. Display student info 7. Add a student to roster 8. Remove a student from roster 9. Exit

  3. How to maintain the roster? • There is no storage (variables) in scheme • The roster has either to be an argument to a function or a return value. • The function to print a menu needs to have an argument for the roster. • Menu (roster)

  4. Menu system • Display the menu • Read input from user • Perform some operation on the roster and continue. • How to do this in scheme? See t1.scm.

  5. Dealing with input • Read 2 items (id and grade) and return the list of just two items just read? (define read-2-items (lambda () (begin (display “input id and grade: “) (list (read) (read)) ) ) Let us say if we want to append this item into the roster list, what to do? See t2.scm

  6. Load from file and store to file • Straight-forward • (write object file) to write the whole roster to a file. • (read file) to read the whole roster from a file.

  7. Sorting • A function (insert item sorted_list) • How? • (Insertionsort l) • (insert (car l) (insertionsort (cdr l))

  8. Order of software development • Do NOT write the whole program in one shot!!!! • One function at a time. Test before considering the next function.

More Related