Exercise index of this lecture   Alphabetic index   Course home   

Exercises
Document Description and Processing in Scheme


false.1   Time tables  

In this exercise we will make a local Cottbus - Görlitz train time table.

Assume, for instance, that we have the following list of defined stations:

 (define stations
  (list "Cottbus" "Spremberg" "Weisswasser" "Horka" "Görlitz"))

Also assume, that the following list gives the number of minutes in between the stations

 (define minutes
  (list 22 12 26 18))

Write a function (time-table start-time) that generates a time table given that the train leaves Cottbus at start-time. Thus for instance this table.

Next, write a function (time-table list-of-start-times) that can generate a more comprehensive time table. Like this one.

I will propose that you give start-time in the universal time format. The Scheme function (current-time) gives the current time.

You can use these functions if you prefer.

 

Solution


false.2   A color-text function  

Write a Scheme markup function color-text of the following form:

  (color-text r g b . content-and-attributes)

The three first parameters are integers between 0 and 255. The tail parameter list text-and-attributes is arbitrary XML contents and attributes.

Examples of calls:

  (color-text 255 0 0 "This is some nice text")
  (color-text 255 0 0 "This is some" (em "nice") "text")
  (color-text 255 0 0 'class "my-class" "This is some" (em "nice") "text" _ ".")

Alternatively you may go for a form:

  (color-text 'red r 'green g 'blue b content-and-attributes)

such as

  (color-text 'red 255 'green 0 'blue 0 "This is some nice text")

Implement the desired function in terms of an HTML span element. Use the function xml-in-laml-positional-abstraction to implement the mixed positional and LAML parameter passing. The function rgb-color-encoding is also useful.

 

Solution


false.3   Table Column Exercise  

This exercises is oriented towards columns of tabular data.

Given three columns of numeric data. Each column is a list of numbers or boolean false values.

The column length may vary from column to column

As an example, the first column col1 may be the list:

  (1 5 #f 9 17)

This column may, together with two other columns, give the following table:


   1 15  8
   5 #f #f
  #f  0 11
   9  6 
  17 

Now, write a Scheme program supported by LAML that presents the table of columns. The table can be represented as the three individual columns. (And this is of course a little tricky, because HTML works with list of rows). #f values should be presented as blank table entries. In the fourth column, you should add the values in each row. When adding, the #f value and missing values (due to short columns) should be treated as 0.

Thus, a function call like (present-table table) should show this table.

 

Solution


Generated: Monday December 19, 2005, 14:16:58