Given students' names along with the grade they are in, create a roster for the school.
In the end, you should be able to:
Note that all our students only have one name (it's a small town, what do you want?), and each student cannot be added more than once to a grade or the roster. If a test attempts to add the same student more than once, your implementation should indicate that this is incorrect.
Define a school tuple to hold the roster — how you store the
students inside it is up to you — then implement the words below.
<school> ( -- school ) — construct an empty school.add-student ( school name grade -- ? ) — add name to
grade. Return t on success, or f if name has already
been added (to this or any other grade), in which case the
roster is left unchanged.roster ( school -- names ) — all students, sorted by grade
and then alphabetically by name.grade ( school n -- names ) — the students in grade n,
sorted alphabetically by name.Sign up to Exercism to learn and master Factor with 47 concepts163 exercises, and real human mentoring, all for free.