Lecture overview -- Keyboard shortcut: 'u'  Previous page: Making tables with the real mirror -- Keyboard shortcut: 'p'  Next page: HTML element modifications -- Keyboard shortcut: 'n'  Lecture notes - all slides and notes together  slide -- Keyboard shortcut: 't'  Textbook -- Keyboard shortcut: 'v'  Help page about these notes  Alphabetic index  Course home    Lecture 4 - Page 30 : 34
Functional Programming in Scheme
Higher-order Functions
Tables with higher-order functions

Instead of explicit composition of td and tr elements we can use a mapping to apply tr to rows and td to elements



(define rows 
  '(("This" "is" "first" "row")
   ("This" "is" "second" "row")
   ("This" "is" "third" "row")
   ("This" "is" "fourth" "row"))

(table 'border 5
   (compose tr (gmap td)) rows))
This is first row
This is second row
This is third row
This is fourth row

In the table expression we map - at the outer level - a composition of tr and a td-mapper. The td-mapper is made by (gmap td).

The last example illustrates that (gmap td) is a useful building block, which can be composed with other functions.

The last example depends on the fact that the HTML mirror functions accept lists of elements and attributes.