(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.
|