PLC: Assignment #6

This assignment is due on April 22nd.

Please read the third chapter ``Environment Passing Interpreters'' in EOPL.

Question 1

There are ca. 17 formula one races every year. For each race, WM points are given on base of the ranking: 10 points for the first, 6 points for the second, 4 to 1 points for the 3rd to 6th ranking, respectively. The WM points are accumulated for the final standings from which the world champion of formula one is determined.

Write a Perl script that computes and prints the final standings from the individual results read from the standard input (or the given file). The input provides for each race the name of the course and the individual rankings. An empty line separates two races. Take as example the first race of 2001:

Australian GP (Melbourne)
1. Michael Schumacher
2. David Coulthard
3. Rubens Barrichello
4. Nick Heidfeld
5. Heinz-Harald Frentzen
6. Kimi Raikkonen

Note that the rankings for the 7th place and beyond are not included because they do not earn WM points. An example input file with the results from 2001 is available.

Question 2

What are the differences between eqv?, eq?, and equal? in Scheme? Write a small procedure which-eq that attempts to recognize the differences using some test cases:

doolin$ guile
guile> (load "which-eq.scm")
guile> (which-eq equal?)
equal?
guile> (which-eq eqv?)
eqv?
guile> (which-eq eq?)
eq?
guile> (which-eq list)
unknown
guile> doolin$

You should add a little test that protects somewhat you from recognizing operators like list as one of the equivalence operators. However, it is perfectly acceptable that other operators like +, if passed to which-eq, lead to errors because of non-matching parameters.

Which of these operators is closest to the == operator in Java?

To solve this question it is recommended to read section 6.1 within R5RS. Note that according to R5RS, some of the possible results of these operators are unspecific. Hence, your program may run differently on different Scheme implementations and it might turn out that some of the operators cannot be distinguished from each other on some implementation. Just describe these observations and tell also which Scheme implementations were used for your tests.

Please submit everything in one email that includes all your answers in attachments. Multiple submission emails are permitted but then only the last one is considered.


Andreas F. Borchert, April 14, 2002