Case Study 2: Complex String Handling
Quasi-string/Quasi-list syntax lighten code

Key Idea: Quasi-strings: {7 * 8 = [(* 7 8)]}
{} indicates string, [] escapes out to Scheme.
Easy to learn/use, clearly lightens code.
; generate HTML histogram table from results of DB query
(define (histogram field table)
   (define results
          {select [field],count(*) from [table] 
            group by [field], order by [field] asc}))

{<html><body> <h1>Query results</h1> The result of query <pre>[s]</pre> is <table> [(trs results)]</table> </body></html>}) (define (trs rows) (map (lambda (row) {<tr> [(tds row)]</tr>\n}) rows)) (define (tds row) (map (lambda (col) {<td> [ col ]</td>}) row))
Similar Scheme approaches: SCRIBE (Serrano), BRL (Lewis), ...

back to top

set preferences

LL2, Saturday 9 November 2002, Tim Hickey/Ken Anderson