Exercises in this lecture   Go to the notes, in which this exercise belongs -- Keyboard shortcut: 'u'   Alphabetic index   Course home   

Exercise solution:
HTML Header functions


Here are the functions that constitute my solution:

(define header-functions (list h1 h2 h3 h4 h5 h6))

(define (header level)
  (if (and (>= level 1) (<= level 6))
      (list-ref header-functions (- level 1))
      id-1))

(define (alternative-header level . optional-parameter-list)
  (let ((txt (optional-parameter 1 optional-parameter-list #f))
        (native-header-function (list-ref header-functions (- level 1)))
       )
    (if txt (native-header-function txt) native-header-function)))