CSC324 Winter 2007 Assignment 2 Marking Addendum CSC324 TAs, Anya Tafliovich and Justin Ward, marked Assignment 2 (A2). A description of the basic marking scheme was included with the A2 solutions. In response to concerns from some students, Anya has prepared the following elaboration. She will also be holding an A2 post-mortem help session for students who have further questions. The time and location of this post-mortem is to be determined. - Sheila --------------------------------------------------------------- Some clarifications on how we graded style. On your A2 papers you will find a lot of feedback re coding style, documentation, efficiency, etc. The purpose of these comments is to help you learn to write good programs in Scheme. Not every comment on your paper corresponds to losing style marks. In fact, most of them don't. If you feel you're unsure what you lost marks for (*AFTER* reading this), you should come to the A2-post-mortem help session, which will be announced shortly. 1) closing parentheses: (define (sub-l x y lst) (cond ((null? lst) ()) ((equal? x (car lst)) (cons y (sub-l x y (cdr lst)) ) ) ((list? (car lst)) (cons (sub-l x y (car lst)) (sub-l x y (cdr lst)) ) ) (else (cons (car lst) (sub-l x y (cdr lst)) ) ) ) ) is not considered good style in Scheme. You're probably used to this style after programming in languages such as Java. In Scheme we write: (define (sub-l x y lst) (cond ((null? lst) ()) ((equal? x (car lst)) (cons y (sub-l x y (cdr lst)))) ((list? (car lst)) (cons (sub-l x y (car lst)) (sub-l x y (cdr lst)))) (else (cons (car lst) (sub-l x y (cdr lst)))))) Marks were *NOT* deducted for this. 2) (if (= (length lst) 0)) is better written as (null? lst) This should be clear. A very small number of marks may be lost for this. All other things good, you have full style marks. Similarly, given that (> (length lst) 0), (if (> (length lst) 4)) is _arguably_ better written as (and (cdr lst) (cddr lst) (cddr lst)) *No* marks were deducted here. 3) In the solutions you will see an efficient implementation of reverse. You were *not* required to implement reverse this way for full marks. 4) Documentation: You will find a lot of feedback re documentation: suggestions on how to write things better, clearer, more concisely, etc. Having these comments does *not* mean you lost marks for documentation. You lost marks for: - absent/incomplete description of the return value - absent/incomplete preconditions - wrong use of postconditions - not including full comments for your helper procedures: return value, preconditions, no reference should be made to the "main" procedure 5) You lost marks for poorly indented code 6) You lost marks for clearly inefficient code: e.g. evaluating the same expression multiple times, reversing the list back and forth, constructing the list in the wrong order and then reversing it, etc. 7) You lost marks for naming your helper procedures "helper". 8) You lost marks for things such as: - (append lst) - (append (list x) y) - (car (list x)) - (if expression #t ()) - (if expression () #t) - (cons x (cons y (cons z (list a (append b) (append w (list v)))))))... - (cond ((cond1 exp1) ... (else (cond ... - (cond ((cond1 exp1) ... (else (if ... - if ... cond ... if ... if .... cond .... else .... if .... .... - if condition then do A else do A - if x >= 0 do A if x < 0 do B else do C - if x >= 0 do A else if x < 0 and y >= 0 do B else if x < 0 and y < 0 and z >=0 do C else do D - badly structured conditionals; for example: (cond (A and B) ... (not A and B) ... (A and not B)... (not A and not B)... (else... Note, that most of these errors are not Scheme-related. These are basic guidelines for good programming. Moreover, all of the above appears in the guidelines on writing good code on the course web-site, as well as in the newsgroup post "some thoughts on A2". I hope this addresses your concerns. However, if you feel you still have questions, I will be happy to answer them in the upcoming a2-post-mortem help session (to be announced shortly). Sincerely, Anya