Lecture overview -- Keyboard shortcut: 'u'  Previous page: The <span>let*</span> name binding construct -- Keyboard shortcut: 'p'  Next page: The <span>letrec</span> namebinding construct -- Keyboard shortcut: 'n'  Lecture notes - all slides and notes together  slide -- Keyboard shortcut: 't'  Help page about these notes  Alphabetic index  Course home  Lecture 1 - Page 40 : 49
Programming Paradigms
Introduction to Functional Programming in Scheme
An example with let*

(define (how-many-days-hours-minutes-seconds n)
  (let* ((days     (quotient n seconds-in-a-day))
         (n-rest-1 (modulo n seconds-in-a-day))
         (hours    (quotient n-rest-1 seconds-in-an-hour))
         (n-rest-2 (modulo n-rest-1 seconds-in-an-hour))
         (minutes  (quotient n-rest-2 60))
         (seconds  (modulo n-rest-2 60))
        ) 
    (list days hours minutes seconds)))

A typical example using sequential name binding. The task is to calculate the number of days, hours, minutes, and seconds given a number of seconds. We subsequently calculate a number of quotients and rest. While doing so we find the desired results. In this example we would not be able to use let; let* is essential because a given calculation depends on previous name bindings. The full example, including the definition of the constants, can be found in the accompanying elucidative program. The function is part of the LAML time library in lib/time.scm of the LAML distribution. The time library is used whenever we need to display time information, such as 'the time of generation' of some HTML files.

c:/Users/Kurt/Teaching-material/Pp-Scheme-17/notes/includes/how-many-hours-minutes-seconds-full.scmA typical example using sequential name binding - all details.