Go to the previous, next section.
(require 'with-file)
Function: with-input-from-file file thunk
Function: with-output-to-file file thunk
Description found in R4RS.
(require 'transcript)
Function: transcript-on filename
Function: transcript-off filename
Redefines read-char
, read
, write-char
,
write
, display
, and newline
.
(require 'rev2-procedures)
The procedures below were specified in the Revised^2 Report on
Scheme. N.B.: The symbols 1+
and -1+
are not
R4RS syntax. Scheme->C, for instance, barfs on this
module.
Procedure: substring-move-left! string1 start1 end1 string2 start2
Procedure: substring-move-right! string1 start1 end1 string2 start2
string1 and string2 must be a strings, and start1, start2 and end1 must be exact integers satisfying
0 <= start1 <= end1 <= (string-length string1) 0 <= start2 <= end1 - start1 + start2 <= (string-length string2)
substring-move-left!
and substring-move-right!
store
characters of string1 beginning with index start1
(inclusive) and ending with index end1 (exclusive) into
string2 beginning with index start2 (inclusive).
substring-move-left!
stores characters in time order of
increasing indices. substring-move-right!
stores characters in
time order of increasing indeces.
Procedure: substring-fill! string start end char
Fills the elements start--end of string with the character char.
== (= 0 (string-length str))
Destructively appends its arguments. Equivalent to nconc
.
Adds 1 to n.
Subtracts 1 from n.
These are equivalent to the procedures of the same name but without the trailing `?'.
(require 'rev3-procedures)
The procedures below were specified in the Revised^3 Report on Scheme.
Returns the last pair in the list l. Example:
(last-pair (cons 1 2)) => (1 . 2) (last-pair '(1 2)) => (2) == (cons 2 '())
Derfined as #t
.
Defined as #f
.
(require 'rev4-optional-procedures)
See R4RS for the specification of these optional procedures.
(require 'mutliarg/and-)
See R4RS for the specification of these optional forms. The
two-arg:
* forms are only defined if the implementation does not
support the many-argument forms.
The original two-argument version of /
.
Function: / divident . divisors
The original two-argument version of -
.
Function: - minuend . subtrahends
See R4RS for the specification of this optional form.
(require 'multiarg-apply)
Function: two-arg:apply proc l
The implementation's native apply
. Only defined for
implementations which don't support the many-argument version.
(require 'rationalize)
The procedure rationalize is interesting because most programming languages do not provide anything analogous to it. For simplicity, we present an algorithm which computes the correct result for exact arguments (provided the implementation supports exact rational numbers of unlimited precision), and produces a reasonable answer for inexact arguments when inexact arithmetic is implemented using floating-point. We thank Alan Bawden for contributing this algorithm.
(require 'promise)
Change occurrences of (delay expression)
to
(make-promise (lambda () expression))
and (define
force promise:force)
to implement promises if your implementation
doesn't support them (see R4RS).
(require 'dynamic-wind)
This facility is a generalization of Common LISP unwind-protect
,
designed to take into account the fact that continuations produced by
call-with-current-continuation
may be reentered.
Procedure: dynamic-wind thunk1 thunk2 thunk3
The arguments thunk1, thunk2, and thunk3 must all be procedures of no arguments (thunks).
dynamic-wind
calls thunk1, thunk2, and then
thunk3. The value returned by thunk2 is returned as the
result of dynamic-wind
. thunk3 is also called just before
control leaves the dynamic context of thunk2 by calling a
continuation created outside that context. Furthermore, thunk1 is
called before reentering the dynamic context of thunk2 by calling
a continuation created inside that context. (Control is inside the
context of thunk2 if thunk2 is on the current return stack).
Warning: There is no provision for dealing with errors or
interrupts. If an error or interrupt occurs while using
dynamic-wind
, the dynamic environment will be that in effect at
the time of the error or interrupt.
(require 'values)
values
takes any number of arguments, and passes (returns) them
to its continuation.
Function: call-with-values thunk proc
thunk must be a procedure of no arguments, and proc must be
a procedure. call-with-values
calls thunk with a
continuation that, when passed some values, calls proc with those
values as arguments.
Except for continuations created by the call-with-values
procedure, all continuations take exactly one value, as now; the effect
of passing no value or more than one value to continuations that were
not created by the call-with-values
procedure is
unspecified.
The procedures current-time
, difftime
, and
offset-time
are supported by all implementations (SLIB provides
them if feature ('current-time)
is missing. current-time
returns a calendar time (caltime) which can be a number or other
type.
Returns the time since 00:00:00 GMT, January 1, 1970, measured in
seconds. Note that the reference time is different from the reference
time for get-universal-time
in section CLTime. On implementations
which cannot support actual times, current-time
will increment a
counter and return its value when called.
Returns the difference (number of seconds) between twe calendar times: caltime1 - caltime0. caltime0 can also be a number.
Returns the calendar time of caltime offset by offset number
of seconds (+ caltime offset)
.
(require 'posix-time)
These procedures are intended to be compatible with Posix time conversion functions.
contains the difference, in seconds, between UTC and local standard time
(for example, in the U.S. Eastern time zone (EST), timezone is
5*60*60). *timezone*
is initialized by tzset
.
initializes the *timezone* variable from the TZ environment variable. This function is automatically called by the other time conversion functions that depend on the time zone.
converts the calendar time caltime to a vector of integers representing the time expressed as Coordinated Universal Time (UTC).
converts the calendar time caltime to a vector of integers expressed
relative to the user's time zone. localtime
sets the variable
*timezone* with the difference between Coordinated Universal Time
(UTC) and local standard time in seconds by calling tzset
.
The elements of the returned vector are as follows:
decode-universal-time
.
Converts a vector of integers in Coordinated Universal Time (UTC) format to calendar time (caltime) format.
Converts the vector of integers caltime in Coordinated
Universal Time (UTC) format into a string of the form
"Wed Jun 30 21:49:08 1993"
.
Equivalent to (time:asctime (time:localtime caltime))
.
Equivalent to (decode-universal-time (get-universal-time))
.
Returns the current time as Universal Time, number of seconds
since 00:00:00 Jan 1, 1900 GMT. Note that the reference time is
different from current-time
.
Function: decode-universal-time univtime
Converts univtime to Decoded Time format. Nine values are returned:
gmtime
and localtime
.
Notice that the values returned by decode-universal-time
do not
match the arguments to encode-universal-time
.
Function: encode-universal-time second minute hour date month year
Function: encode-universal-time second minute hour date month year time-zone
Converts the arguments in Decoded Time format to Universal Time format. If time-zone is not specified, the returned time is adjusted for daylight saving time. Otherwise, no adjustment is performed.
Notice that the values returned by decode-universal-time
do not
match the arguments to encode-universal-time
.
Go to the previous, next section.