Functional Programming: Quiz 2, due in written by 13.12.2000

Index

  1. Write a function up_run that gives the length of the longest up sequence of consecutive integers in a list. For each pair in an up sequence [...a,b,...] a< b. Implement this in SML and me too. Test case: up_run([1,2,3,2,3,4,5,2,3])=4.

  2. Define an algorithm for fast computation of ak based on successive squaring (binary representation of k) . Implement this in SML and me too. Test case: 2**9=512.

  3. A class register shows students and the subjects they study, and a timetable shows which subjects are taught during which lessons:
           
                 Register = map(Student, set(Subject))
                 Timetable = map(Subject, set(Lesson))
    
    (a) Define an operation lessons, which takes a student, a register and a timetable and returns the set of lessons attended by that student.
    (b) Define an operation attends, which returns the set of students who attend a particular lesson.
    (c) Define an operation no_clashes, which, for a given register and timetable returns true if there is no timetable clashes. (A clash occurs when two subjects taken by the same student have lessons in parallel - i.e. they occupy the same lesson slot in the timetable).

    Make a complete me too design following the me too method for this problem, including implementation and validation.