Lecture overview -- Keyboard shortcut: 'u'  Previous page: The XHTML mirror in LAML -- Keyboard shortcut: 'p'    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 34 : 34
Functional Programming in Scheme
Higher-order Functions
Generation of a leq predicate from enumeration

In some contexts we wish to specify a number of clauses in an arbitrary order

For presentational clarity, we often want to ensure that the clauses are presented in a particular order

Here we want to generate a leq predicate from an enumeration of the desired order



(define simple-leq? 
  (generate-leq '(z a c b y x) id-1))

(sort-list '(a x y z c c b a) simple-leq?)
(z a a c c b y x)

A simple example of an application of generate-leq.

 (form '(show-table rows))
 (title "show-table")
 (description "Presents the table, in terms of rows")
 (parameter "row" "a list of elements")
 (pre-condition "Must be placed before the begin-notes clause")
 (misc "Internally, sets the variable lecture-id")
 (result "returns an HTML string")

A hypothetical manual page clause. Before we present the clauses of the manual page we want to ensure, that they appear in a particular order, say title, form, description, pre-condition, result, and misc. In this example we will illustrate how to obtain such an ordering in an elegant manner.

y:/Kurt/Files/courses/prog3/prog3-03/sources/notes/includes/generate-leq.scmThe functions generate-leq and the helping function list-index .

y:/Kurt/Files/courses/prog3/prog3-03/sources/notes/includes/generate-leq/generate-leq-application.scmAn application of generate-leq which sorts the manual clauses.