Expression | Value | (define document
(let
((html
(xml-modify-element html
'xmlns "http://www.w3.org/1999/xhtml"))
(body
(xml-modify-element body
'bgcolor (rgb-color-encoding 255 0 0)))
)
(lambda (ttl bdy)
(html
(head (title ttl))
(body bdy))))) | | (document "A title" "A body") | <html xmlns =
"http://www.w3.org/1999/xhtml">
<head>
<title>A title</title>
</head>
<body bgcolor = "#ff0000">
A body
</body>
</html> |
| | An example in which we abstract a (html (head (title..)) (body ...)) expression
in a lambda expression, of which we define a private context. The context redefines
the html and body functions to 'specialized' versions, with certain attributes.
Notice the importance of the 'simultaneous name bindings' of let in the example
(as explained in an earlier lecture). Also notice that we have discussed
the modify-element higher-order function before. |