Functions for attribute linearization. | Lecture 4 - slide 27 : 34 Program 4 |
(define (linearize-attributes attr-list) (string-append (linearize-attributes-1 (reverse attr-list) "" (length attr-list)))) (define (linearize-attributes-1 attr-list res-string lgt) (cond ((null? attr-list) res-string) ((>= lgt 2) (linearize-attributes-1 (cddr attr-list) (string-append (linearize-attribute-pair (car attr-list) (cadr attr-list)) " " res-string) (- lgt 2))) ((< lgt 2) (error "The attribute list must have even length")))) (define (linearize-attribute-pair val attr) (string-append (as-string attr) " = " (string-it (as-string val))))