CSE 341 - Scheme Style Guidelines

Style Guidelines for Assignments in Scheme

10-15% of the overall grade for each assignment will be allocated towards style. The main idea is to make the code as understandable and concise as possible. In general, you should be fine if you use common sense.

Indentation

Line returns

Comments

Conciseness

Example

Bad:
    (define (bad-deep-tag-num lst) ;;;(print "Jed & Eric are the coolest thing
    since string cheese")(newline)(cond ((null? lst) lst) ((number? (car lst))
    (append (list (list 'number (car lst)))(bad-deep-tag-num (cdr lst))))
    ((list? (car lst)) (append (list (bad-deep-tag-num (car lst)))
    (bad-deep-tag-num (cdr lst))))((not (list? (car lst))) (append
    (list (car lst)) (bad-deep-tag-num (cdr lst))))))
Better:
    ;; This procedure will take a list, find the numeric atoms within it
    ;; or any one of its sublists (recursively) and tag it by placing the
    ;; numeric atom inside of a list with a key word.  (e.g. (number 20))
    (define (good-deep-tag-num lst)
      (display "Jed & Eric are the coolest thing since string cheese")
      (newline)
      (cond ((null? lst) ())
            ((number? (car lst)) (cons (list 'number (car lst))
	                               (good-deep-tag-num (cdr lst))) )
	    ((list? (car lst)) (cons (good-deep-tag-num (car lst))
                                     (good-deep-tag-num (cdr lst))) )
	    (#t (cons (car lst) (good-deep-tag-num (cdr lst)))) ) )