r7rs-small-texinfo

Unnamed repository; edit this file 'description' to name the repository.
git clone https://kaka.farm/~git/r7rs-small-texinfo
Log | Files | Refs

commit fa52e1a671fc3b05747e51bff5bcb70d862685b2
parent 3d79ab7133529da1a28c25a81ad35ee8891f41a4
Author: Wolfgang Corcoran-Mathe <wcm@sigwinch.xyz>
Date:   Sat,  3 Feb 2024 13:11:35 -0500

Use @lisp instead of @example throughout.

Diffstat:
Mdoc/r7rs-small/basic-concepts.texinfo | 8++++----
Mdoc/r7rs-small/derived-expressions-implementation.texinfo | 72++++++++++++++++++++++++++++++++++++------------------------------------
Mdoc/r7rs-small/derived/binding-constructs.texinfo | 24++++++++++++------------
Mdoc/r7rs-small/derived/case-lambda.texinfo | 4++--
Mdoc/r7rs-small/derived/conditionals.texinfo | 20++++++++++----------
Mdoc/r7rs-small/derived/delayed-evaluation.texinfo | 20++++++++++----------
Mdoc/r7rs-small/derived/dynamic-bindings.texinfo | 4++--
Mdoc/r7rs-small/derived/exception-handling.texinfo | 4++--
Mdoc/r7rs-small/derived/iteration.texinfo | 8++++----
Mdoc/r7rs-small/derived/quasiquotation.texinfo | 20++++++++++----------
Mdoc/r7rs-small/derived/sequencing.texinfo | 4++--
Mdoc/r7rs-small/lexical-conventions.texinfo | 24++++++++++++------------
Mdoc/r7rs-small/macros.texinfo | 28++++++++++++++--------------
Mdoc/r7rs-small/overview.texinfo | 4++--
Mdoc/r7rs-small/primitive-expressions.texinfo | 40++++++++++++++++++++--------------------
Mdoc/r7rs-small/procedures/booleans.texinfo | 12++++++------
Mdoc/r7rs-small/procedures/bytevectors.texinfo | 32++++++++++++++++----------------
Mdoc/r7rs-small/procedures/characters.texinfo | 12++++++------
Mdoc/r7rs-small/procedures/control-features.texinfo | 48++++++++++++++++++++++++------------------------
Mdoc/r7rs-small/procedures/environments-and-evaluation.texinfo | 4++--
Mdoc/r7rs-small/procedures/equivalence-predicates.texinfo | 24++++++++++++------------
Mdoc/r7rs-small/procedures/exceptions.texinfo | 12++++++------
Mdoc/r7rs-small/procedures/input-and-output.texinfo | 4++--
Mdoc/r7rs-small/procedures/numbers.texinfo | 68++++++++++++++++++++++++++++++++++----------------------------------
Mdoc/r7rs-small/procedures/pairs-and-lists.texinfo | 72++++++++++++++++++++++++++++++++++++------------------------------------
Mdoc/r7rs-small/procedures/strings.texinfo | 8++++----
Mdoc/r7rs-small/procedures/symbols.texinfo | 12++++++------
Mdoc/r7rs-small/procedures/system-interface.texinfo | 16++++++++--------
Mdoc/r7rs-small/procedures/vectors.texinfo | 36++++++++++++++++++------------------
Mdoc/r7rs-small/program-structure.texinfo | 60++++++++++++++++++++++++++++++------------------------------
Mdoc/r7rs-small/scheme-example.texinfo | 20++++++++++----------
31 files changed, 362 insertions(+), 362 deletions(-)

diff --git a/doc/r7rs-small/basic-concepts.texinfo b/doc/r7rs-small/basic-concepts.texinfo @@ -239,12 +239,12 @@ The last expression within the body of a lambda expression, shown as <tail expression> below, occurs in a tail context. The same is true of all the bodies of @code{case-lambda} expressions. -@example +@lisp (lambda @svar{formals} @svar{definition}* @svar{expression}* @svar{tail expression}) (case-lambda (@svar{formals} @svar{tail body})*) -@end example +@end lisp @item If one of the following expressions is in a tail context, then the @@ -324,13 +324,13 @@ In the following example the only tail call is the call to @code{f}. None of the calls to @code{g} or @code{h} are tail calls. The reference to @code{x} is in a tail context, but it is not a call and thus is not a tail call. -@example +@lisp (lambda () (if (g) (let ((x (h))) x) (and (g) (f)))) -@end example +@end lisp @subheading Note diff --git a/doc/r7rs-small/derived-expressions-implementation.texinfo b/doc/r7rs-small/derived-expressions-implementation.texinfo @@ -7,7 +7,7 @@ quasiquote. Conditional derived syntax types: -@example +@lisp (define-syntax cond (syntax-rules (else =>) ((cond (else result1 result2 ...)) @@ -93,11 +93,11 @@ Conditional derived syntax types: ((unless test result1 result2 ...) (if (not test) (begin result1 result2 ...))))) -@end example +@end lisp Binding constructs: -@example +@lisp (define-syntax let (syntax-rules () ((let ((name val) ...) body1 body2 ...) @@ -118,7 +118,7 @@ Binding constructs: (let ((name1 val1)) (let* ((name2 val2) ...) body1 body2 ...))))) -@end example +@end lisp The following letrec macro uses the symbol @svar{undefined} in place of an expression which returns something that when stored in a location makes it an error to try to obtain the @@ -126,7 +126,7 @@ value stored in the location. (No such expression is defined in Scheme.) A trick generate the temporary names needed to avoid specifying the order in which the values are evaluated. This could also be accomplished by using an auxiliary macro. -@example +@lisp (define-syntax letrec (syntax-rules () ((letrec ((var1 init1) ...) body ...) @@ -253,13 +253,13 @@ are evaluated. This could also be accomplished by using an auxiliary macro. (syntax-rules () ((begin exp ...) ((lambda () exp ...))))) -@end example +@end lisp The following alternative expansion for begin does not make use of the ability to write more than one expression in the body of a lambda expression. In any case, note that these rules apply only if the body of the begin contains no definitions. -@example +@lisp (define-syntax begin (syntax-rules () ((begin exp) @@ -269,13 +269,13 @@ these rules apply only if the body of the begin contains no definitions. (lambda () exp1) (lambda args (begin exp2 ...)))))) -@end example +@end lisp The following syntax definition of do uses a trick to expand the variable clauses. As with letrec above, an auxiliary macro would also work. The expression (if #f #f) is used to obtain an unspecific value. -@example +@lisp (define-syntax do (syntax-rules () ((do ((var init step ...) ...) @@ -298,65 +298,65 @@ obtain an unspecific value. x) ((do "step" x y) y))) -@end example +@end lisp Here is a possible implementation of delay, force and delay-force. We define the expression -@example +@lisp (delay-force @svar{expression}) -@end example +@end lisp to have the same meaning as the procedure call -@example +@lisp (make-promise #f (lambda () @svar{expression})) -@end example +@end lisp as follows -@example +@lisp (define-syntax delay-force (syntax-rules () ((delay-force expression) (make-promise #f (lambda () expression))))) -@end example +@end lisp and we define the expression -@example +@lisp (delay @svar{expression}) -@end example +@end lisp to have the same meaning as: -@example +@lisp (delay-force (make-promise #t @svar{expression})) -@end example +@end lisp as follows -@example +@lisp (define-syntax delay (syntax-rules () ((delay expression) (delay-force (make-promise #t expression))))) -@end example +@end lisp where make-promise is defined as follows: -@example +@lisp (define make-promise (lambda (done? proc) (list (cons done? proc)))) -@end example +@end lisp Finally, we define force to call the procedure expressions in promises iteratively using a trampoline technique following [38] until a non-lazy result (i.e. a value created by delay instead of delay-force) is returned, as follows: -@example +@lisp (define (force promise) (if (promise-done? promise) (promise-value promise) @@ -364,11 +364,11 @@ is returned, as follows: (unless (promise-done? promise) (promise-update! promise* promise)) (force promise)))) -@end example +@end lisp with the following promise accessors: -@example +@lisp (define promise-done? (lambda (x) (car (car x)))) (define promise-value @@ -378,14 +378,14 @@ with the following promise accessors: (set-car! (car old) (promise-done? new)) (set-cdr! (car old) (promise-value new)) (set-car! new (car old)))) -@end example +@end lisp The following implementation of make-parameter and parameterize is suitable for an implementation with no threads. Parameter objects are implemented here as procedures, using two arbitrary unique objects @svar{param-set!} and @svar{param-convert}: -@example +@lisp (define (make-parameter init . o) (let* ((converter (if (pair? o) (car o) (lambda (x) x))) @@ -400,12 +400,12 @@ implemented here as procedures, using two arbitrary unique objects @svar{param-s converter) (else (error "bad parameter syntax")))))) -@end example +@end lisp Then parameterize uses dynamic-wind to dynamically rebind the associated value: -@example +@lisp (define-syntax parameterize (syntax-rules () ((parameterize ("step") @@ -432,12 +432,12 @@ dynamically rebind the associated value: () ((param value) ...) body)))) -@end example +@end lisp The following implementation of guard depends on an auxiliary macro, here called guard-aux. -@example +@lisp (define-syntax guard (syntax-rules () ((guard (var clause ...) e1 e2 ...) @@ -520,12 +520,12 @@ guard-aux. args) (cl . rest)))))) (cl (params body0 ...) ...))))))) -@end example +@end lisp This definition of cond-expand does not interact with the features procedure. It requires that each feature identifier provided by the implementation be explicitly mentioned. -@example +@lisp (define-syntax cond-expand ;; Extend this to mention all feature ids and libraries (syntax-rules (and or not else r7rs library scheme base) @@ -584,4 +584,4 @@ that each feature identifier provided by the implementation be explicitly mentio body ...) more-clauses ...) (cond-expand more-clauses ...)))) -@end example +@end lisp diff --git a/doc/r7rs-small/derived/binding-constructs.texinfo b/doc/r7rs-small/derived/binding-constructs.texinfo @@ -34,7 +34,7 @@ holding the results, the @svar{body} is evaluated in the extended environment, and the values of the last expression of @svar{body} are returned. Each binding of a @svar{variable} has @svar{body} as its region. -@example +@lisp (let ((x 2) (y 3)) (* x y)) @result{} 6 @@ -42,7 +42,7 @@ returned. Each binding of a @svar{variable} has @svar{body} as its region. (let ((x 7) (z (+ x y))) (* z x))) @result{} 35 -@end example +@end lisp See also ``named @code{let},'' @ref{Iteration}. @end deffn @@ -65,12 +65,12 @@ that part of the @code{let*} expression to the right of the binding. Thus the second binding is done in an environment in which the first binding is visible, and so on. The @svar{variable}s need not be distinct. -@example +@lisp (let ((x 2) (y 3)) (let* ((x 7) (z (+ x y))) (* z x))) @result{} 70 -@end example +@end lisp @end deffn @deffn syntax letrec @svar{bindings} @svar{body} @@ -95,7 +95,7 @@ the resulting environment, and the values of the last expression in letrec expression as its region, making it possible to define mutually recursive procedures. -@example +@lisp (letrec ((even? (lambda (n) (if (zero? n) @@ -108,7 +108,7 @@ recursive procedures. (even? (- n 1)))))) (even? 88)) @result{} #t -@end example +@end lisp One restriction on @code{letrec} is very important: if it is not possible to evaluate each @svar{init} without assigning or referring to the value of any @@ -147,7 +147,7 @@ referring to the value of the corresponding @svar{variable} or the is an error. Another restriction is that it is an error to invoke the continuation of an @svar{init} more than once. -@example +@lisp ;; Returns the arithmetic, geometric, and ;; harmonic means of a nested list of numbers (define (means ton) @@ -167,7 +167,7 @@ continuation of an @svar{init} more than once. (values (mean values values) (mean exp log) (mean / /)))) -@end example +@end lisp Evaluating @code{(means '(3 (1 4)))} returns three values: 8/3, 2.28942848510666 (approximately), and 36/19. @@ -200,10 +200,10 @@ the extended environment, and the values of the last expression of It is an error if the @svar{formals} do not match the number of values returned by the corresponding @svar{init}. -@example +@lisp (let-values (((root rem) (exact-integer-sqrt 32))) (* root rem)) @result{} 35 -@end example +@end lisp @end deffn @deffn syntax let*-values @svar{mv binding spec} @svar{body} @@ -225,10 +225,10 @@ right, with the region of the bindings of each @svar{formals} including the @svar{init} is evaluated in an environment in which the first set of bindings is visible and initialized, and so on. -@example +@lisp (let ((a 'a) (b 'b) (x 'x) (y 'y)) (let*-values (((a b) (values x y)) ((x y) (values a b))) (list a b x y))) @result{} (x y x y) -@end example +@end lisp @end deffn diff --git a/doc/r7rs-small/derived/case-lambda.texinfo b/doc/r7rs-small/derived/case-lambda.texinfo @@ -18,7 +18,7 @@ results of the procedure call. It is an error for the arguments not to agree with the @svar{formals} of any @svar{clause}. -@example +@lisp (define range (case-lambda ((e) (range 0 e)) @@ -28,6 +28,6 @@ It is an error for the arguments not to agree with the @svar{formals} of any @sv (range 3) @result{} (0 1 2) (range 3 5) @result{} (3 4) -@end example +@end lisp @end deffn diff --git a/doc/r7rs-small/derived/conditionals.texinfo b/doc/r7rs-small/derived/conditionals.texinfo @@ -45,7 +45,7 @@ clause, then its @svar{expression}s are evaluated in order, and the values of the last one are returned. @end deffn -@example +@lisp (cond ((> 3 2) 'greater) ((< 3 2) 'less)) @result{} greater @@ -55,7 +55,7 @@ of the last one are returned. (cond ((assv 'b '((a 1) (b 2))) => cadr) (else #f)) @result{} 2 -@end example +@end lisp @deffn syntax case @svar{key} @svar{clause@sub{1}} @svar{clause@sub{2}}@dots{} @@ -105,7 +105,7 @@ the value of the @svar{key} and the values returned by this procedure are returned by the @code{case} expression. @end deffn -@example +@lisp (case (* 2 3) ((2 3 5 7) 'prime) ((1 4 6 8 9) 'composite)) @result{} composite @@ -116,7 +116,7 @@ returned by the @code{case} expression. ((a e i o u) 'vowel) ((w y) 'semivowel) (else => (lambda (x) x))) @result{} c -@end example +@end lisp @deffn syntax and @svar{test@sub{1}}@dots{} @@ -127,12 +127,12 @@ expressions evaluate to true values, the values of the last expression are returned. If there are no expressions, then @code{#t} is returned. @end deffn -@example +@lisp (and (= 2 2) (> 2 1)) @result{} #t (and (= 2 2) (< 2 1)) @result{} #f (and 1 2 'c '(f g)) @result{} (f g) (and) @result{} #t -@end example +@end lisp @deffn syntax or @svar{test@sub{1}}@dots{} @@ -143,13 +143,13 @@ If all expressions evaluate to @code{#f} or if there are no expressions, then @code{#f} is returned. @end deffn -@example +@lisp (or (= 2 2) (> 2 1)) @result{} #t (or (= 2 2) (< 2 1)) @result{} #t (or #f #f #f) @result{} #f (or (memq 'b '(a b c)) (/ 3 0)) @result{} (b c) -@end example +@end lisp @deffn syntax when @svar{test} @svar{expression@sub{1}} @svar{expression@sub{2}}@dots{} @@ -160,12 +160,12 @@ expressions are evaluated in order. The result of the @code{when} expression is unspecified. @end deffn -@example +@lisp (when (= 1 1.0) (display "1") (display "2")) @result{} @r{unspecified} @print{} 12 -@end example +@end lisp @deffn syntax unless @svar{test} @svar{expression@sub{1}} @svar{expression@sub{2}}@dots{} diff --git a/doc/r7rs-small/derived/delayed-evaluation.texinfo b/doc/r7rs-small/derived/delayed-evaluation.texinfo @@ -44,7 +44,7 @@ values and exception handler of the call to @code{force} which first requested its value. If @var{promise} is not a promise, it may be returned unchanged. -@example +@lisp (force (delay (+ 1 2))) @result{} 3 (let ((p (delay (+ 1 2)))) (list (force p) (force p))) @@ -62,7 +62,7 @@ If @var{promise} is not a promise, it may be returned unchanged. (head (tail (tail integers))) @result{} 2 -@end example +@end lisp @end deffn @@ -75,7 +75,7 @@ ever-growing sequence of pending promises does not exhaust available storage, because @code{force} will in effect force such sequences iteratively. -@example +@lisp (define (stream-filter p? s) (delay-force (if (null? (force s)) @@ -87,7 +87,7 @@ because @code{force} will in effect force such sequences iteratively. (stream-filter p? t)))))) (head (tail (tail (stream-filter odd? integers)))) @result{} 5 -@end example +@end lisp The following examples are not intended to illustrate good programming style, as @code{delay}, @code{force}, and @code{delay-force} are mainly intended @@ -95,7 +95,7 @@ for programs written in the functional style. However, they do illustrate the property that only one value is computed for a promise, no matter how many times it is forced. -@example +@lisp (define count 0) (define p (delay (begin (set! count (+ count 1)) @@ -108,7 +108,7 @@ p @result{} @r{a promise} p @result{} @r{a promise, still} (begin (set! x 10) (force p)) @result{} 6 -@end example +@end lisp Various extensions to this semantics of @code{delay}, @code{force} and @code{delay-force} are supported in some implementations: @@ -122,10 +122,10 @@ It may be the case that there is no means by which a promise can be operationall distinguished from its forced value. That is, expressions like the following may evaluate to either @code{#t} or to @code{#f}, depending on the implementation: -@example +@lisp (eqv? (delay 1) 1) @result{} @r{unspecified} (pair? (delay (cons 1 2))) @result{} @r{unspecified} -@end example +@end lisp @item Implementations may implement ``implicit forcing,'' where the value of a promise is @@ -135,11 +135,11 @@ Implementations may implement ``implicit forcing,'' where the value of a promise @code{list}, must not force them. -@example +@lisp (+ (delay (* 3 7)) 13) @result{} @r{unspecified} (car (list (delay (* 3 7)) 13)) @result{} @r{a promise} -@end example +@end lisp @end itemize @deffn {lazy library procedure} promise? obj diff --git a/doc/r7rs-small/derived/dynamic-bindings.texinfo b/doc/r7rs-small/derived/dynamic-bindings.texinfo @@ -58,7 +58,7 @@ Parameter objects can be used to specify configurable settings for a computation without the need to pass the value to every procedure in the call chain explicitly. -@example +@lisp (define radix (make-parameter 10 @@ -78,6 +78,6 @@ procedure in the call chain explicitly. (parameterize ((radix 0)) (f 12)) @error{} -@end example +@end lisp @end deffn diff --git a/doc/r7rs-small/derived/exception-handling.texinfo b/doc/r7rs-small/derived/exception-handling.texinfo @@ -28,7 +28,7 @@ exception handler is that of the @code{guard} expression. @xref{Exceptions} for a more complete discussion of exceptions. -@example +@lisp (guard (condition ((assq 'a condition) => cdr) ((assq 'b condition))) @@ -40,6 +40,6 @@ exception handler is that of the @code{guard} expression. ((assq 'b condition))) (raise (list (cons 'b 23)))) @result{} (b . 23) -@end example +@end lisp @end deffn diff --git a/doc/r7rs-small/derived/iteration.texinfo b/doc/r7rs-small/derived/iteration.texinfo @@ -49,7 +49,7 @@ A @svar{step} can be omitted, in which case the effect is the same as if @code{(}@svar{variable} @svar{init} @svar{variable}@code{)} had been written instead of @code{(}@svar{variable} @svar{init}@code{)}. -@example +@lisp (do ((vec (make-vector 5)) (i 0 (+ i 1))) ((= i 5) vec) @@ -59,7 +59,7 @@ been written instead of @code{(}@svar{variable} @svar{init}@code{)}. (do ((x x (cdr x)) (sum 0 (+ sum (car x)))) ((null? x) sum))) @result{} 25 -@end example +@end lisp @end deffn @@ -74,7 +74,7 @@ whose formal arguments are the bound variables and whose body is @svar{body}. Thus the execution of @svar{body} can be repeated by invoking the procedure named by @svar{variable}. -@example +@lisp (let loop ((numbers '(3 -2 1 6 -5)) (nonneg '()) (neg '())) @@ -88,6 +88,6 @@ invoking the procedure named by @svar{variable}. nonneg (cons (car numbers) neg))))) @result{} ((6 1 3) (-5 -2)) -@end example +@end lisp @end deffn diff --git a/doc/r7rs-small/derived/quasiquotation.texinfo b/doc/r7rs-small/derived/quasiquotation.texinfo @@ -29,7 +29,7 @@ Note: In order to unquote an identifier beginning with @code{,} it is necessary an explicit unquote or to put whitespace after the comma, to avoid colliding with the comma at-sign sequence. -@example +@lisp `(list ,(+ 1 2) 4) @result{} (list 3 4) (let ((name 'a)) `(list ,name ',name)) @@ -47,14 +47,14 @@ comma at-sign sequence. (let ((foo '(foo bar)) (@@baz 'baz)) `(list ,@@foo , @@baz)) @result{} (list foo bar baz) -@end example +@end lisp Quasiquote expressions can be nested. Substitutions are made only for unquoted components appearing at the same nesting level as the outermost quasiquote. The nesting level increases by one inside each successive quasiquotation, and decreases by one inside each unquotation. -@example +@lisp `(a `(b ,(+ 1 2) ,(foo ,(+ 1 3) d) e) f) @result{} (a `(b ,(+ 1 2) ,(foo 4 d) e) f) @@ -62,7 +62,7 @@ decreases by one inside each unquotation. (name2 'y)) `(a `(b ,,name1 ,',name2 d) e)) @result{} (a `(b ,x ,'y d) e) -@end example +@end lisp A quasiquote expression may return either newly allocated, mutable objects or literal structure for any structure that is constructed at run time during the @@ -70,19 +70,19 @@ evaluation of the expression. Portions that do not need to be rebuilt are always Thus, @code{(let ((a 3)) `((1 2) ,a ,4 ,'five 6))} may be treated as equivalent to either of the following expressions: -@example +@lisp `((1 2) 3 4 five 6) (let ((a 3)) (cons '(1 2) (cons a (cons 4 (cons 'five '(6)))))) -@end example +@end lisp However, it is not equivalent to this expression: -@example +@lisp (let ((a 3)) (list (list 1 2) a 4 'five 6)) -@end example +@end lisp The two notations @code{`}@svar{qq template} and @code{(quasiquote }@svar{qq template}@code{)} @@ -91,14 +91,14 @@ are identical in all respects. @code{,}@svar{expression} is identical to is identical to @code{(unquote-splicing }@svar{expression}@code{)}. The write procedure may output either format. -@example +@lisp (quasiquote (list (unquote (+ 1 2)) 4)) @result{} (list 3 4) '(quasiquote (list (unquote (+ 1 2)) 4)) @result{} `(list ,(+ 1 2) 4) @r{i.e.}, (quasiquote (list (unquote (+ 1 2)) 4)) -@end example +@end lisp It is an error if any of the identifiers @code{quasiquote}, @code{unquote}, or @code{unquote-splicing} appear in positions within a @svar{qq template} diff --git a/doc/r7rs-small/derived/sequencing.texinfo b/doc/r7rs-small/derived/sequencing.texinfo @@ -24,7 +24,7 @@ evaluated sequentially from left to right, and the values of the last @svar{expr returned. This expression type is used to sequence side effects such as assignments or input and output. -@example +@lisp (define x 0) (and (= x 0) @@ -35,7 +35,7 @@ input and output. (display (+ 4 1))) @result{} @r{unspecified} @print{} 4 plus 1 equals 5 -@end example +@end lisp @end deffn diff --git a/doc/r7rs-small/lexical-conventions.texinfo b/doc/r7rs-small/lexical-conventions.texinfo @@ -21,9 +21,9 @@ single period) used in the list syntax is not an identifier. All implementations of Scheme must support the following extended identifier characters: -@example +@lisp ! $ % & * + - . / : < = > ? @ ^ _ ~ -@end example +@end lisp Alternatively, an identifier can be represented by a sequence of zero or more characters enclosed within vertical lines (@samp{|}), analogous to string literals. @@ -38,7 +38,7 @@ that @code{||} is a valid identifier that is different from any other identifier Here are some examples of identifiers: -@example +@lisp ... + +soup+ <=? ->string a34kTMNs @@ -46,7 +46,7 @@ lambda list->vector q V17a |two words| |two\x20;words| the-word-recursion-has-many-meanings -@end example +@end lisp See section 7.1.1 for the formal syntax of identifiers. @@ -74,10 +74,10 @@ sentence. The following directives give explicit control over case folding. -@example +@lisp #!fold-case #!no-fold-case -@end example +@end lisp These directives can appear anywhere comments are permitted (see section 2.2) but must be followed by a delimiter. They are treated as comments, except that they affect @@ -108,7 +108,7 @@ useful for ``commenting out'' sections of code. Block comments are indicated with properly nested @code{#|} and @code{|#} pairs. -@example +@lisp #| The FACT procedure computes the factorial of a non-negative integer. @@ -119,7 +119,7 @@ Block comments are indicated with properly nested @code{#|} and @code{|#} pairs. #;(= n 1) 1 ;Base case: return 1 (* n (fact (- n 1)))))) -@end example +@end lisp @node Other notations @section Other notations @@ -200,11 +200,11 @@ The lexical syntax @code{#}<n>@code{#} serves as a reference to some object labe result is the same object as the @code{#}<n>@code{=} (see section 6.1). Together, these syntaxes permit the notation of structures with shared or circular substructure. -@example +@lisp (let ((x (list 'a 'b 'c))) (set-cdr! (cddr x) x) x) @result{} #0=(a b c . #0#) -@end example +@end lisp The scope of a datum label is the portion of the outermost datum in which it appears that is to the right of the label. Consequently, a reference @code{#}<n>@code{#} can occur only after a label @@ -215,7 +215,7 @@ labelled by @code{#}<n>@code{=} is not well defined in this case. It is an error for a <program> or <library> to include circular references except in literals. In particular, it is an error for quasiquote (section 4.2.8) to contain them. -@example +@lisp #1=(begin (display #\x) #1#) @result{} @error{} -@end example +@end lisp @end deffn diff --git a/doc/r7rs-small/macros.texinfo b/doc/r7rs-small/macros.texinfo @@ -93,7 +93,7 @@ expression with macros whose keywords are the @svar{keyword}s, bound to the specified transformers. Each binding of a @svar{keyword} has @svar{body} as its region. -@example +@lisp (let-syntax ((given-that (syntax-rules () ((given-that test stmt1 stmt2 ...) (if test @@ -107,7 +107,7 @@ to the specified transformers. Each binding of a @svar{keyword} has (let-syntax ((m (syntax-rules () ((m) x)))) (let ((x 'inner)) (m)))) @result{} outer -@end example +@end lisp @end deffn @@ -123,7 +123,7 @@ environment obtained by extending the syntactic environment of the within its region, so the transformers can transcribe expressions into uses of the macros introduced by the @code{letrec-syntax} expression. -@example +@lisp (letrec-syntax ((my-or (syntax-rules () ((my-or) #f) @@ -142,7 +142,7 @@ uses of the macros introduced by the @code{letrec-syntax} expression. (let temp) (if y) y))) @result{} 7 -@end example +@end lisp @end deffn @@ -337,7 +337,7 @@ the template @code{(}@svar{ellipsis} @svar{ellipsis}@svar{)} produces a single @svar{ellipsis}. This allows syntactic abstractions to expand into code containing ellipses. -@example +@lisp (define-syntax be-like-begin (syntax-rules () ((be-like-begin name) @@ -348,34 +348,34 @@ into code containing ellipses. (be-like-begin sequence) (sequence 1 2 3 4) @result{} 4 -@end example +@end lisp As an example, if @code{let} and @code{cond} are defined as in @ref{Derived expression types formal} then they are hygienic (as required) and the following is not an error. -@example +@lisp (let ((=> #f)) (cond (#t => 'ok))) @result{} ok -@end example +@end lisp The macro transformer for @code{cond} recognizes @code{=>} as a local variable, and hence an expression, and not as the base identifier @code{=>}, which the macro transformer treats as a syntactic keyword. Thus the example expands into -@example +@lisp (let ((=> #f)) (if #t (begin => 'ok))) -@end example +@end lisp instead of -@example +@lisp (let ((=> #f)) (let ((temp #t)) (if temp ('ok temp)))) -@end example +@end lisp which would result in an invalid procedure call. @@ -395,7 +395,7 @@ messages. @svar{message} is a string literal, and @svar{args} arbitrary expressions providing additional information. Applications cannot count on being able to catch syntax errors with exception handlers or guards. -@example +@lisp (define-syntax simple-let (syntax-rules () ((_ (head ... ((x . y) val) . tail) @@ -406,6 +406,6 @@ being able to catch syntax errors with exception handlers or guards. ((_ ((name val) ...) body1 body2 ...) ((lambda (name ...) body1 body2 ...) val ...)))) -@end example +@end lisp @end deffn diff --git a/doc/r7rs-small/overview.texinfo b/doc/r7rs-small/overview.texinfo @@ -356,9 +356,9 @@ string, then the entire string is referred to. The symbol ``@result{}'' used in program examples is read ``evaluates to.'' For example, -@example +@lisp (* 5 8) @result{} 40 -@end example +@end lisp means that the expression @code{(* 5 8)} evaluates to the object @code{40}. Or, more precisely: the expression given by the sequence of characters ``@code{(* 5 8)}'' evaluates, in an diff --git a/doc/r7rs-small/primitive-expressions.texinfo b/doc/r7rs-small/primitive-expressions.texinfo @@ -22,10 +22,10 @@ reference. The value of the variable reference is the value stored in the location to which the variable is bound. It is an error to reference an unboundvariable. -@example +@lisp (define x 28) x @result{} 28 -@end example +@end lisp @node Literal expressions @subsection Literal expressions @@ -39,29 +39,29 @@ external representation of a Scheme object (@xref{External representations basic}). This notation is used to include literal constants in Scheme code. -@example +@lisp (quote a) @result{} a (quote #(a b c)) @result{} #(a b c) (quote (+ 1 2)) @result{} (+ 1 2) -@end example +@end lisp @code{(quote} @svar{datum}@code{)} can be abbreviated as @code{'}@svar{datum}. The two notations are equivalent in all respects. -@example +@lisp 'a @result{} a '#(a b c) @result{} #(a b c) '() @result{} () '(+ 1 2) @result{} (+ 1 2) '(quote a) @result{} (quote a) ''a @result{} (quote a) -@end example +@end lisp Numerical constants, string constants, character constants, vector constants, bytevector constants, and boolean constants evaluate to themselves; they need not be quoted. -@example +@lisp '145932 @result{} 145932 145932 @result{} 145932 '"abc" @result{} "abc" @@ -74,7 +74,7 @@ themselves; they need not be quoted. #u8(64 65) @result{} #u8(64 65) '#t @result{} #t #t @result{} #t -@end example +@end lisp As noted in @ref{Storage model}, it is an error to attempt to alter a constant (i.e.@: the value of a literal expression) using a mutation @@ -91,10 +91,10 @@ passed to it. The operator and operand expressions are evaluated (in an unspecified order) and the resulting procedure is passed the resulting arguments. -@example +@lisp (+ 3 4) @result{} 7 ((if #f + *) 3 4) @result{} 12 -@end example +@end lisp The procedures in this document are available as the values of variables exported by the standard libraries. For example, the addition and @@ -142,12 +142,12 @@ constructs}) will be evaluated sequentially in the extended environment. The results of the last expression in the body will be returned as the results of the procedure call. -@example +@lisp ((lambda (x) (+ x x)) @result{} @r{a procedure} ((lambda (x) (+ x x)) 4) @result{} 8 -@end example +@end lisp -@example +@lisp (define reverse-subtract (lambda (x y) (- y x))) (reverse-subtract 7 10) @result{} 3 @@ -156,7 +156,7 @@ of the procedure call. (let ((x 4)) (lambda (y) (+ x y)))) (add4 6) @result{} 10 -@end example +@end lisp @svar{Formals} have one of the following forms: @@ -186,11 +186,11 @@ formal arguments. It is an error for a @svar{variable} to appear more than once in @svar{formals}. -@example +@lisp ((lambda x x) 3 4 5 6) @result{} (3 4 5 6) ((lambda (x y . z) z) 3 4 5 6) @result{} (5 6) -@end example +@end lisp Each procedure created as the result of evaluating a @code{lambda} expression is (conceptually) tagged with a storage location, in order to @@ -214,13 +214,13 @@ yields a false value and no @svar{alternate} is specified, then the result of the expression is unspecified. @end deffn -@example +@lisp (if (> 3 2) 'yes 'no) @result{} yes (if (> 2 3) 'yes 'no) @result{} no (if (> 3 2) (- 3 2) (+ 3 2)) @result{} 1 -@end example +@end lisp @node Assignments @subsection Assignments @@ -234,12 +234,12 @@ expression or else globally. The result of the @code{set!} expression is unspecified. @end deffn -@example +@lisp (define x 2) (+ x 1) @result{} 3 (set! x 4) @result{} @r{unspecified} (+ x 1) @result{} 5 -@end example +@end lisp @node Inclusion @subsection Inclusion diff --git a/doc/r7rs-small/procedures/booleans.texinfo b/doc/r7rs-small/procedures/booleans.texinfo @@ -17,11 +17,11 @@ from each other and from the symbol nil. Boolean constants evaluate to themselves, so they do not need to be quoted in programs. -@example +@lisp #t @result{} #t #f @result{} #f '#f @result{} #f -@end example +@end lisp @deffn procedure not obj @@ -29,7 +29,7 @@ The not procedure returns #t if obj is false, and returns #f otherwise. -@example +@lisp (not #t) @result{} #f (not 3) @result{} #f (not (list 3)) @result{} #f @@ -37,7 +37,7 @@ obj is false, and returns #f otherwise. (not '()) @result{} #f (not (list)) @result{} #f (not 'nil) @result{} #f -@end example +@end lisp @end deffn @deffn procedure boolean? obj @@ -46,11 +46,11 @@ The boolean? predicate returns #t if obj is either #t or #f and returns #f otherwise. -@example +@lisp (boolean? #f) @result{} #t (boolean? 0) @result{} #f (boolean? '()) @result{} #f -@end example +@end lisp @end deffn @deffn procedure boolean=? boolean1 boolean2 boolean3 @dots{} diff --git a/doc/r7rs-small/procedures/bytevectors.texinfo b/doc/r7rs-small/procedures/bytevectors.texinfo @@ -37,19 +37,19 @@ byte is given, then all elements of the bytevector are initialized to byte, otherwise the contents of each element are unspecified. -@example +@lisp (make-bytevector 2 12) @result{} #u8(12 12) -@end example +@end lisp @end deffn @deffn procedure bytevector byte@dots{} Returns a newly allocated bytevector containing its arguments. -@example +@lisp (bytevector 1 3 5 1 3 5) @result{} #u8(1 3 5 1 3 5) (bytevector) @result{} #u8() -@end example +@end lisp @end deffn @deffn procedure bytevector-length bytevector @@ -73,11 +73,11 @@ kth byte of bytevector. -@example +@lisp (bytevector-u8-ref '#u8(1 1 2 3 5 8 13 21) 5) @result{} 8 -@end example +@end lisp @end deffn @deffn procedure bytevector-u8-set! bytevector k byte @@ -96,12 +96,12 @@ kth byte of bytevector. -@example +@lisp (let ((bv (bytevector 1 2 3 4))) (bytevector-u8-set! bv 1 3) bv) @result{} #u8(1 3 3 4) -@end example +@end lisp @end deffn @deffn procedure bytevector-copy bytevector @@ -116,10 +116,10 @@ start and end. -@example +@lisp (define a #u8(1 2 3 4 5)) (bytevector-copy a 2 4)) @result{} #u8(3 4) -@end example +@end lisp @end deffn @deffn procedure bytevector-copy! to at from @@ -155,12 +155,12 @@ destination overlap, copying takes place as if the source is first copied into a bytevector and then into the destination. This can be achieved without allocating storage by making sure to copy in the correct direction in such circumstances. -@example +@lisp (define a (bytevector 1 2 3 4 5)) (define b (bytevector 10 20 30 40 50)) (bytevector-copy! b 1 a 0 2) b @result{} #u8(10 1 2 40 50) -@end example +@end lisp Note: This procedure appears in R6RS, but places the source before the destination, contrary to other such procedures in Scheme. @@ -171,10 +171,10 @@ Note: This procedure appears in R6RS, but places the source before the destinati Returns a newly allocated bytevector whose elements are the concatenation of the elements in the given bytevectors. -@example +@lisp (bytevector-append #u8(0 1 2) #u8(3 4 5)) @result{} #u8(0 1 2 3 4 5) -@end example +@end lisp @end deffn @deffn procedure utf8->string bytevector @@ -201,8 +201,8 @@ start and end and returns the corresponding bytevector. -@example +@lisp (utf8->string #u8(#x41)) @result{} "A" (string->utf8 "λ") @result{} #u8(#xCE #xBB) -@end example +@end lisp @end deffn diff --git a/doc/r7rs-small/procedures/characters.texinfo b/doc/r7rs-small/procedures/characters.texinfo @@ -15,7 +15,7 @@ The following character names must be supported by all implementations with the values. Implementations may add other names provided they cannot be interpreted as hex scalar values preceded by x. -@example +@lisp #\alarm ; U+0007 #\backspace ; U+0008 #\delete ; U+007F @@ -25,18 +25,18 @@ hex scalar values preceded by x. #\return ; the return character, U+000D #\space ; the preferred way to write a space #\tab ; the tab character, U+0009 -@end example +@end lisp Here are some additional examples: -@example +@lisp #\a ; lower case letter #\A ; upper case letter #\( ; left parenthesis #\ ; the space character #\x03BB ; @theultimate{} (if character is supported) #\iota ; @greekiota{} (if character and name are supported) -@end example +@end lisp Case is significant in #\@svar{character}, and in #\⟨character name⟩, but not in #\x<hex scalar value>. If @svar{character} in #\@svar{character} is alphabetic, then any character immediately @@ -102,12 +102,12 @@ alphabetic but neither upper nor lower case. This procedure returns the numeric value (0 to 9) of its argument if it is a numeric digit (that is, if char-numeric? returns #t), or #f on any other character. -@example +@lisp (digit-value #\3) @result{} 3 (digit-value #\x0664) @result{} 4 (digit-value #\x0AE6) @result{} 0 (digit-value #\x0EA6) @result{} #f -@end example +@end lisp @end deffn @deffn procedure char->integer char diff --git a/doc/r7rs-small/procedures/control-features.texinfo b/doc/r7rs-small/procedures/control-features.texinfo @@ -12,7 +12,7 @@ Returns #t if obj is a procedure, otherwise returns #f. -@example +@lisp (procedure? car) @result{} #t (procedure? 'car) @result{} #f (procedure? (lambda (x) (* x x))) @@ -21,7 +21,7 @@ obj is a procedure, otherwise returns #f. @result{} #f (call-with-current-continuation procedure?) @result{} #t -@end example +@end lisp @end deffn @deffn procedure apply proc arg1@dots{} args @@ -30,7 +30,7 @@ The apply procedure calls proc with the elements of the list @code{(append (list arg1 @dots{}) args)} as the actual arguments. -@example +@lisp (apply + (list 3 4)) @result{} 7 (define compose @@ -39,7 +39,7 @@ proc with the elements of the list @code{(append (list arg1 @dots{}) args)} as t (f (apply g args))))) ((compose sqrt *) 12 75) @result{} 30 -@end example +@end lisp @end deffn @deffn procedure map proc list1 list2@dots{} @@ -66,7 +66,7 @@ proc is applied to the elements of the lists is unspecified. If multiple returns occur from map, the values returned by earlier returns are not mutated. -@example +@lisp (map cadr '((a b) (d e) (g h))) @result{} (b e h) @@ -83,7 +83,7 @@ returns are not mutated. '(a b))) @result{} (1 2) or (2 1) -@end example +@end lisp @end deffn @deffn procedure string-map proc string1 string2@dots{} @@ -107,7 +107,7 @@ proc is applied to the elements of the strings is unspecified. If multiple returns occur from string-map, the values returned by earlier returns are not mutated. -@example +@lisp (string-map char-foldcase "AbdEgH") @result{} "abdegh" @@ -124,7 +124,7 @@ earlier returns are not mutated. "studlycaps xxx" "ululululul") @result{} "StUdLyCaPs" -@end example +@end lisp @end deffn @deffn procedure vector-map proc vector1 vector2@dots{} @@ -147,7 +147,7 @@ proc is applied to the elements of the vectors is unspecified. If multiple returns occur from vector-map, the values returned by earlier returns are not mutated. -@example +@lisp (vector-map cadr '#((a b) (d e) (g h))) @result{} #(b e h) @@ -166,7 +166,7 @@ earlier returns are not mutated. '#(a b))) @result{} #(1 2) or #(2 1) -@end example +@end lisp @end deffn @deffn procedure for-each proc list1 list2@dots{} @@ -194,13 +194,13 @@ It is an error for proc to mutate any of the lists. -@example +@lisp (let ((v (make-vector 5))) (for-each (lambda (i) (vector-set! v i (* i i))) '(0 1 2 3 4)) v) @result{} #(0 1 4 9 16) -@end example +@end lisp @end deffn @deffn procedure string-for-each proc string1 string2@dots{} @@ -225,13 +225,13 @@ the shortest string runs out. It is an error for proc to mutate any of the strings. -@example +@lisp (let ((v '())) (string-for-each (lambda (c) (set! v (cons (char->integer c) v))) "abcde") v) @result{} (101 100 99 98 97) -@end example +@end lisp @end deffn @deffn procedure vector-for-each proc vector1 vector2@dots{} @@ -256,13 +256,13 @@ the shortest vector runs out. It is an error for proc to mutate any of the vectors. -@example +@lisp (let ((v (make-list 5))) (vector-for-each (lambda (i) (list-set! v i (* i i))) '#(0 1 2 3 4)) v) @result{} (0 1 4 9 16) -@end example +@end lisp @end deffn @deffn procedure call-with-current-continuation proc @@ -307,7 +307,7 @@ call-with-current-continuation is used. If all real uses were as simple as these there would be no need for a procedure with the power of call-with-current-continuation. -@example +@lisp (call-with-current-continuation (lambda (exit) (for-each (lambda (x) @@ -331,7 +331,7 @@ call-with-current-continuation. (list-length '(1 2 3 4)) @result{} 4 (list-length '(a b . c)) @result{} #f -@end example +@end lisp Rationale: A common use of call-with-current-continuation is for structured, non-local exits from loops or procedure bodies, but in fact @@ -358,11 +358,11 @@ Rationale: A common use of call-with-current-continuation is for structured, Delivers all of its arguments to its continuation. The values procedure might be defined as follows: -@example +@lisp (define (values . things) (call-with-current-continuation (lambda (cont) (apply cont things)))) -@end example +@end lisp @end deffn @deffn procedure call-with-values producer consumer @@ -376,13 +376,13 @@ consumer procedure with those values as arguments. The continuation for the call consumer is the continuation of the call to call-with-values. -@example +@lisp (call-with-values (lambda () (values 4 5)) (lambda (a b) b)) @result{} 5 (call-with-values * -) @result{} -1 -@end example +@end lisp @end deffn @deffn procedure dynamic-wind before thunk after @@ -453,7 +453,7 @@ before or after is unspecified. -@example +@lisp (let ((path '()) (c #f)) (let ((add (lambda (s) @@ -472,5 +472,5 @@ after is unspecified. @result{} (connect talk1 disconnect connect talk2 disconnect) -@end example +@end lisp @end deffn diff --git a/doc/r7rs-small/procedures/environments-and-evaluation.texinfo b/doc/r7rs-small/procedures/environments-and-evaluation.texinfo @@ -74,7 +74,7 @@ returned. If it is a definition, the specified identifier(s) are defined in the environment, provided the environment is not immutable. Implementations may extend eval to allow other objects. -@example +@lisp (eval '(* 7 3) (environment '(scheme base))) @result{} 21 @@ -85,5 +85,5 @@ eval to allow other objects. (eval '(define foo 32) (environment '(scheme base))) @result{} error is signaled -@end example +@end lisp @end deffn diff --git a/doc/r7rs-small/procedures/equivalence-predicates.texinfo b/doc/r7rs-small/procedures/equivalence-predicates.texinfo @@ -115,7 +115,7 @@ for some arguments. @end itemize -@example +@lisp (eqv? 'a 'a) @result{} #t (eqv? 'a 'b) @result{} #f (eqv? 2 2) @result{} #t @@ -129,13 +129,13 @@ for some arguments. (let ((p (lambda (x) x))) (eqv? p p)) @result{} #t (eqv? #f 'nil) @result{} #f -@end example +@end lisp The following examples illustrate cases in which the above rules do not fully specify the behavior of @code{eqv?}. All that can be said about such cases is that the value returned by @code{eqv?} must be a boolean. -@example +@lisp (eqv? "" "") @result{} @r{unspecified} (eqv? '#() '#()) @result{} @r{unspecified} (eqv? (lambda (x) x) @@ -144,7 +144,7 @@ such cases is that the value returned by @code{eqv?} must be a boolean. (lambda (y) y)) @result{} @r{unspecified} (eqv? 1.0e0 1.0f0) @result{} @r{unspecified} (eqv? +nan.0 +nan.0) @result{} @r{unspecified} -@end example +@end lisp Note that @code{(eqv? 0.0 -0.0)} will return @code{#f} if negative zero is distinguished, and @code{#t} if negative zero is not distinguished. @@ -157,7 +157,7 @@ operationally equivalent procedures each time, since the local state does not affect the value or side effects of the procedures. However, @code{eqv?} may or may not detect this equivalence. -@example +@lisp (define gen-counter (lambda () (let ((n 0)) @@ -188,20 +188,20 @@ does not affect the value or side effects of the procedures. However, (g (lambda () (if (eqv? f g) 'g 'both)))) (eqv? f g)) @result{} #f -@end example +@end lisp Since it is an error to modify constant objects (those returned by literal expressions), implementations may share structure between constants where appropriate. Thus the value of @code{eqv?} on constants is sometimes implementation-dependent. -@example +@lisp (eqv? '(a) '(a)) @result{} @r{unspecified} (eqv? "a" "a") @result{} @r{unspecified} (eqv? '(b) (cdr '(a b))) @result{} @r{unspecified} (let ((x '(a))) (eqv? x x)) @result{} #t -@end example +@end lisp The above definition of @code{eqv?} allows implementations latitude in their treatment of procedures and literals: implementations may either @@ -234,7 +234,7 @@ it will always return either true or false. On empty strings, empty vectors, and empty bytevectors, @code{eq?} may also behave differently from @code{eqv?}. -@example +@lisp (eq? 'a 'a) @result{} #t (eq? '(a) '(a)) @result{} @r{unspecified} (eq? (list 'a) (list 'a)) @result{} #f @@ -252,7 +252,7 @@ from @code{eqv?}. (eq? x x)) @result{} #t (let ((p (lambda (x) x))) (eq? p p)) @result{} #t -@end example +@end lisp Rationale: It will usually be possible to implement @code{eq?} much more efficiently than @code{eqv?}, for example, as a simple pointer @@ -276,7 +276,7 @@ other cases, @code{equal?} may return either @code{#t} or @code{#f}. Even if its arguments are circular data structures, @code{equal?} must always terminate. -@example +@lisp (equal? 'a 'a) @result{} #t (equal? '(a) '(a)) @result{} #t (equal? '(a (b) c) @@ -289,7 +289,7 @@ always terminate. '#2=(a b a b . #2#)) @result{} #t (equal? (lambda (x) x) (lambda (y) y)) @result{} @r{unspecified} -@end example +@end lisp Note: A rule of thumb is that objects are generally @code{equal?} if they print the same. diff --git a/doc/r7rs-small/procedures/exceptions.texinfo b/doc/r7rs-small/procedures/exceptions.texinfo @@ -31,7 +31,7 @@ for the invocation of thunk. -@example +@lisp (call-with-current-continuation (lambda (k) (with-exception-handler @@ -53,7 +53,7 @@ thunk. prints something went wrong After printing, the second example then raises another exception. -@end example +@end lisp @end deffn @deffn procedure raise obj @@ -78,7 +78,7 @@ place when the handler being called was installed, and (2) if the handler being returns, then it will again become the current exception handler. If the handler returns, the values it returns become the values returned by the call to raise-continuable. -@example +@lisp (with-exception-handler (lambda (con) (cond @@ -92,7 +92,7 @@ the values it returns become the values returned by the call to raise-continuabl 23))) prints: should be a number @result{} 65 -@end example +@end lisp @end deffn @deffn procedure error message obj @dots{} @@ -106,7 +106,7 @@ message, as well as any objs, known as the irritants. The procedure error-object? must return #t on such objects. -@example +@lisp (define (null-list? l) (cond ((pair? l) #f) ((null? l) #t) @@ -114,7 +114,7 @@ objs, known as the irritants. The procedure error-object? must return #t on such (error "null-list?: argument out of domain" l)))) -@end example +@end lisp @end deffn @deffn procedure error-object? obj diff --git a/doc/r7rs-small/procedures/input-and-output.texinfo b/doc/r7rs-small/procedures/input-and-output.texinfo @@ -179,7 +179,7 @@ port was not created with open-output-string. Returns a string consisting of the characters that have been output to the port so far in the order they were output. If the result string is modified, the effect is unspecified. -@example +@lisp (parameterize ((current-output-port (open-output-string))) @@ -190,7 +190,7 @@ the order they were output. If the result string is modified, the effect is unsp (get-output-string (current-output-port))) @result{} "piece by piece by piece.\n" -@end example +@end lisp @end deffn @deffn procedure open-input-bytevector bytevector diff --git a/doc/r7rs-small/procedures/numbers.texinfo b/doc/r7rs-small/procedures/numbers.texinfo @@ -477,12 +477,12 @@ The @code{infinite?} procedure returns @code{#t} on the real numbers or imaginary parts or both are infinite. Otherwise it returns @code{#f}. -@example +@lisp (infinite? 3) @result{} #f (infinite? +inf.0) @result{} #t (infinite? +nan.0) @result{} #f (infinite? 3.0+inf.0i) @result{} #t -@end example +@end lisp @end deffn @deffn {inexact library procedure} nan? z @@ -491,12 +491,12 @@ The @code{nan?} procedure returns @code{#t} on @code{+nan.0}, and on complex numbers if their real or imaginary parts or both are @code{+nan.0}. Otherwise it returns @code{#f}. -@example +@lisp (nan? +nan.0) @result{} #t (nan? 32) @result{} #f (nan? +nan.0+5.0i) @result{} #t (nan? 1+2i) @result{} #f -@end example +@end lisp @end deffn @deffn procedure = z@sub{1} z@sub{2} z@sub{3}@dots{} @@ -548,10 +548,10 @@ returning @code{#t} or @code{#f}. See note above. These procedures return the maximum or minimum of their arguments. -@example +@lisp (max 3 4) @result{} 4 ; exact (max 3.9 4) @result{} 4.0 ; inexact -@end example +@end lisp Note: If any argument is inexact, then the result will also be inexact (unless the procedure can prove that the inaccuracy is not large enough to @@ -568,13 +568,13 @@ of an implementation restriction. These procedures return the sum or product of their arguments. -@example +@lisp (+ 3 4) @result{} 7 (+ 3) @result{} 3 (+) @result{} 0 (* 4) @result{} 4 (*) @result{} 1 -@end example +@end lisp @end deffn @deffn procedure - z @@ -591,13 +591,13 @@ It is an error if any argument of @code{/} other than the first is an exact zero. If the first argument is an exact zero, an implementation may return an exact zero unless one of the other arguments is a NaN. -@example +@lisp (- 3 4) @result{} -1 (- 3 4 5) @result{} -6 (- 3) @result{} -3 (/ 3 4 5) @result{} 3/20 (/ 3) @result{} 1/3 -@end example +@end lisp @end deffn @@ -605,9 +605,9 @@ may return an exact zero unless one of the other arguments is a NaN. The abs procedure returns the absolute value of its argument. -@example +@lisp (abs -7) @result{} 7 -@end example +@end lisp @end deffn @@ -661,7 +661,7 @@ provided all numbers involved in that computation are exact. Examples: -@example +@lisp (floor/ 5 2) @result{} 2 1 (floor/ -5 2) @result{} -3 1 (floor/ 5 -2) @result{} -3 -1 @@ -671,7 +671,7 @@ Examples: (truncate/ 5 -2) @result{} -2 1 (truncate/ -5 -2) @result{} 2 -1 (truncate/ -5.0 -2) @result{} 2.0 -1.0 -@end example +@end lisp @end deffn @@ -694,13 +694,13 @@ earlier versions of this report. These procedures return the greatest common divisor or least common multiple of their arguments. The result is always non-negative. -@example +@lisp (gcd 32 -36) @result{} 4 (gcd) @result{} 0 (lcm 32 -36) @result{} 288 (lcm 32.0 -36) @result{} 288.0 ; inexact (lcm) @result{} 1 -@end example +@end lisp @end deffn @@ -712,12 +712,12 @@ the result is computed as if the argument was represented as a fraction in lowest terms. The denominator is always positive. The denominator of 0 is defined to be 1. -@example +@lisp (numerator (/ 6 4)) @result{} 3 (denominator (/ 6 4)) @result{} 2 (denominator (inexact (/ 6 4))) @result{} 2.0 -@end example +@end lisp @end deffn @@ -743,7 +743,7 @@ result will also be inexact. If an exact value is needed, the result can be passed to the @code{exact} procedure. If the argument is infinite or a NaN, then it is returned. -@example +@lisp (floor -4.3) @result{} -5.0 (ceiling -4.3) @result{} -4.0 (truncate -4.3) @result{} -4.0 @@ -756,7 +756,7 @@ a NaN, then it is returned. (round 7/2) @result{} 4 ; exact (round 7) @result{} 7 -@end example +@end lisp @end deffn @@ -774,10 +774,10 @@ rational number that is simpler than every other rational number in that interval (the simpler 2/5 lies between 2/7 and 3/5). Note that 0 = 0/1 is the simplest rational of all. -@example +@lisp (rationalize (exact .3) 1/10) @result{} 1/3 ; exact (rationalize .3 1/10) @result{} #i1/3 ; inexact -@end example +@end lisp @end deffn @@ -876,10 +876,10 @@ these procedures produce a real result from a real argument. Returns the square of z. This is equivalent to @code{(* }@var{z} @var{z}@code{)}. -@example +@lisp (square 42) @result{} 1764 (square 2.0) @result{} 4.0 -@end example +@end lisp @end deffn @@ -889,10 +889,10 @@ Returns the principal square root of @var{z}. The result will have either a positive real part, or a zero real part and a non-negative imaginary part. -@example +@lisp (sqrt 9) @result{} 3 (sqrt -1) @result{} +i -@end example +@end lisp @end deffn @@ -901,10 +901,10 @@ imaginary part. Returns two non-negative exact integers @var{s} and @var{r} where @var{k} = @var{s}@sup{2} + @var{r} and @var{k} < (@var{s} + 1)@sup{2}. -@example +@lisp (exact-integer-sqrt 4) @result{} 2 0 (exact-integer-sqrt 5) @result{} 2 1 -@end example +@end lisp @end deffn @@ -939,14 +939,14 @@ z = x_1 + x_{2}i = x_3 \cdot e^{i x_4} Then all of -@example +@lisp (make-rectangular @r{@var{x@sub{1}} @var{x@sub{2}}}) @result{} z (make-polar @r{@var{x@sub{3}} @var{x@sub{4}}}) @result{} z (real-part @r{@var{z}}) @result{} @r{@var{x@sub{1}}} (imag-part @r{@var{z}}) @result{} @r{@var{x@sub{2}}} (magnitude @r{@var{z}}) @result{} |@r{@var{x@sub{3}}}| (angle @r{@var{z}}) @result{} @r{@var{x}@sub{angle}} -@end example +@end lisp are true, where @minus{}@greekpi{} @leq{} @var{x@sub{angle}} @leq{} @greekpi{} with @var{x@sub{angle}} = @var{x@sub{4}} + 2@greekpi{}@var{n} @@ -1013,14 +1013,14 @@ The procedure @code{number->string} takes a number and a radix and returns as a string an external representation of the given number in the given radix such that -@example +@lisp (let ((number number) (radix radix)) (eqv? number (string->number (number->string number radix) radix))) -@end example +@end lisp is true. It is an error if no possible result makes this expression true. If omitted, @var{radix} defaults to 10. @@ -1059,11 +1059,11 @@ would result in a number that the implementation cannot represent, then @code{string->number} returns @code{#f}. An error is never signaled due to the content of @var{string}. -@example +@lisp (string->number "100") @result{} 100 (string->number "100" 16) @result{} 256 (string->number "1e2") @result{} 100.0 -@end example +@end lisp Note: The domain of @code{string->number} may be restricted by implementations in the following ways. If all numbers supported by an diff --git a/doc/r7rs-small/procedures/pairs-and-lists.texinfo b/doc/r7rs-small/procedures/pairs-and-lists.texinfo @@ -95,12 +95,12 @@ The pair? predicate returns #t if obj is a pair, and otherwise returns #f. -@example +@lisp (pair? '(a . b)) @result{} #t (pair? '(a b c)) @result{} #t (pair? '()) @result{} #f (pair? '#(a b)) @result{} #f -@end example +@end lisp @end deffn @deffn procedure cons obj1 obj2 @@ -112,13 +112,13 @@ obj1 and whose cdr is obj2. The pair is guaranteed to be different (in the sense of eqv?) from every existing object. -@example +@lisp (cons 'a '()) @result{} (a) (cons '(a) '(b c d)) @result{} ((a) b c d) (cons "a" '(b c)) @result{} ("a" b c) (cons 'a 3) @result{} (a . 3) (cons '(a b) 'c) @result{} ((a b) . c) -@end example +@end lisp @end deffn @deffn procedure car pair @@ -127,12 +127,12 @@ Returns the contents of the car field of pair. Note that it is an error to take the car of the empty list. -@example +@lisp (car '(a b c)) @result{} a (car '((a) b c d)) @result{} (a) (car '(1 . 2)) @result{} 1 (car '()) @result{} error -@end example +@end lisp @end deffn @deffn procedure cdr pair @@ -141,11 +141,11 @@ Returns the contents of the cdr field of pair. Note that it is an error to take the cdr of the empty list. -@example +@lisp (cdr '((a) b c d)) @result{} (b c d) (cdr '(1 . 2)) @result{} 2 (cdr '()) @result{} error -@end example +@end lisp @end deffn @deffn procedure set-car! pair obj @@ -178,12 +178,12 @@ pair. These procedures are compositions of car and cdr as follows: -@example +@lisp (define (caar x) (car (car x))) (define (cadr x) (car (cdr x))) (define (cdar x) (cdr (car x))) (define (cddr x) (cdr (cdr x))) -@end example +@end lisp @end deffn @deffn {cxr library procedure} caaar @var{pair} @@ -195,9 +195,9 @@ These procedures are compositions of car and cdr as follows: These twenty-four procedures are further compositions of car and cdr on the same principles. For example, caddr could be defined by -@example +@lisp (define caddr (lambda (x) (car (cdr (cdr x))))). -@end example +@end lisp Arbitrary compositions up to four deep are provided. @@ -218,14 +218,14 @@ Returns #t if obj is a list. Otherwise, it returns #f. By definition, all lists have finite length and are terminated by the empty list. -@example +@lisp (list? '(a b c)) @result{} #t (list? '()) @result{} #t (list? '(a . b)) @result{} #f (let ((x (list 'a))) (set-cdr! x x) (list? x)) @result{} #f -@end example +@end lisp @end deffn @deffn procedure make-list k @@ -237,30 +237,30 @@ k elements. If a second argument is given, then each element is initialized to fill. Otherwise the initial contents of each element is unspecified. -@example +@lisp (make-list 2 3) @result{} (3 3) -@end example +@end lisp @end deffn @deffn procedure list obj @dots{} Returns a newly allocated list of its arguments. -@example +@lisp (list 'a (+ 3 4) 'c) @result{} (a 7 c) (list) @result{} () -@end example +@end lisp @end deffn @deffn procedure length list Returns the length of @var{list}. -@example +@lisp (length '(a b c)) @result{} 3 (length '(a (b) (c d e))) @result{} 3 (length '()) @result{} 0 -@end example +@end lisp @end deffn @deffn procedure append list@dots{} @@ -274,14 +274,14 @@ argument, it is returned. Otherwise the resulting list is always newly allocated, except that it shares structure with the last argument. An improper list results if the last argument is not a proper list. -@example +@lisp (append '(x) '(y)) @result{} (x y) (append '(a) '(b c d)) @result{} (a b c d) (append '(a (b)) '((c))) @result{} (a (b) (c)) (append '(a b) '(c . d)) @result{} (a b c . d) (append '() 'a) @result{} a -@end example +@end lisp @end deffn @deffn procedure reverse list @@ -289,11 +289,11 @@ improper list results if the last argument is not a proper list. Returns a newly allocated list consisting of the elements of @var{list} in reverse order. -@example +@lisp (reverse '(a b c)) @result{} (c b a) (reverse '(a (b c) d (e (f)))) @result{} ((e (f)) d (b c) a) -@end example +@end lisp @end deffn @deffn procedure list-tail list k @@ -310,13 +310,13 @@ list obtained by omitting the first k elements. The list-tail procedure could be defined by -@example +@lisp (define list-tail (lambda (x k) (if (zero? k) x (list-tail (cdr x) (- k 1))))) -@end example +@end lisp @end deffn @deffn procedure list-ref list k @@ -339,12 +339,12 @@ list k).) -@example +@lisp (list-ref '(a b c d) 2) @result{} c (list-ref '(a b c d) (exact (round 1.8))) @result{} c -@end example +@end lisp @end deffn @deffn procedure list-set! list k obj @@ -363,7 +363,7 @@ k of list. -@example +@lisp (let ((ls (list 'one 'two 'five!))) (list-set! ls 2 'three) ls) @@ -371,7 +371,7 @@ list. (list-set! '(0 1 2) 1 "oops") @result{} error ; constant list -@end example +@end lisp @end deffn @deffn procedure memq obj list @@ -405,7 +405,7 @@ list, while memv uses eqv? and member uses compare, if given, and equal? otherwise. -@example +@lisp (memq 'a '(a b c)) @result{} (a b c) (memq 'b '(a b c)) @result{} (b c) (memq 'a '(b c d)) @result{} #f @@ -417,7 +417,7 @@ compare, if given, and equal? otherwise. string-ci=?) @result{} ("b" "c") (memq 101 '(100 101 102)) @result{} unspecified (memv 101 '(100 101 102)) @result{} (101 102) -@end example +@end lisp @end deffn @deffn procedure assq obj alist @@ -446,7 +446,7 @@ alist, while assv uses eqv? and assoc uses compare if given and equal? otherwise. -@example +@lisp (define e '((a 1) (b 2) (c 3))) (assq 'a e) @result{} (a 1) (assq 'b e) @result{} (b 2) @@ -461,7 +461,7 @@ compare if given and equal? otherwise. @result{} unspecified (assv 5 '((2 3) (5 7) (11 13))) @result{} (5 7) -@end example +@end lisp Rationale: Although they are often used as predicates, memq, memv, member, assq, assv, and assoc do not have question marks in their names because they return @@ -484,11 +484,11 @@ obj which is not a list is returned unchanged. It is an error if obj is a circular list. -@example +@lisp (define a '(1 8 2 8)) ; a may be immutable (define b (list-copy a)) (set-car! b 3) ; b is mutable b @result{} (3 8 2 8) a @result{} (1 8 2 8) -@end example +@end lisp @end deffn diff --git a/doc/r7rs-small/procedures/strings.texinfo b/doc/r7rs-small/procedures/strings.texinfo @@ -141,7 +141,7 @@ k of string. There is no requirement for this procedure to execute in constant time. -@example +@lisp (define (f) (make-string 3 #\*)) (define (g) "***") (string-set! (f) 0 #\?) @result{} unspecified @@ -149,7 +149,7 @@ string. There is no requirement for this procedure to execute in constant time. (string-set! (symbol->string 'immutable) 0 #\?) @result{} error -@end example +@end lisp @end deffn @deffn procedure string=? string1 string2 string3 @dots{} @@ -298,12 +298,12 @@ destination overlap, copying takes place as if the source is first copied into a string and then into the destination. This can be achieved without allocating storage by making sure to copy in the correct direction in such circumstances. -@example +@lisp (define a "12345") (define b (string-copy "abcde")) (string-copy! b 1 a 0 2) b @result{} "a12de" -@end example +@end lisp @end deffn @deffn procedure string-fill! string fill diff --git a/doc/r7rs-small/procedures/symbols.texinfo b/doc/r7rs-small/procedures/symbols.texinfo @@ -23,14 +23,14 @@ Returns #t if obj is a symbol, otherwise returns #f. -@example +@lisp (symbol? 'foo) @result{} #t (symbol? (car '(a b))) @result{} #t (symbol? "bar") @result{} #f (symbol? 'nil) @result{} #t (symbol? '()) @result{} #f (symbol? #f) @result{} #f -@end example +@end lisp @end deffn @deffn procedure symbol=? symbol1 symbol2 symbol3 @dots{} @@ -48,14 +48,14 @@ Returns the name of symbol as a string, but without adding escapes. It is an error to apply mutation procedures like string-set! to strings returned by this procedure. -@example +@lisp (symbol->string 'flying-fish) @result{} "flying-fish" (symbol->string 'Martin) @result{} "Martin" (symbol->string (string->symbol "Malvina")) @result{} "Malvina" -@end example +@end lisp @end deffn @deffn procedure string->symbol string @@ -65,7 +65,7 @@ Returns the symbol whose name is string. This procedure can create symbols with names containing special characters that would require escaping when written, but does not interpret escapes in its input. -@example +@lisp (string->symbol "mISSISSIppi") @result{}mISSISSIppi (eqv? 'bitBlt (string->symbol "bitBlt")) @@ -78,5 +78,5 @@ would require escaping when written, but does not interpret escapes in its input (symbol->string (string->symbol "K. Harper, M.D."))) @result{} #t -@end example +@end lisp @end deffn diff --git a/doc/r7rs-small/procedures/system-interface.texinfo b/doc/r7rs-small/procedures/system-interface.texinfo @@ -105,10 +105,10 @@ to encode the name and decode the value of the environment variable. It is an er get-environment-variable can't decode the value. It is also an error to mutate the resulting string. -@example +@lisp (get-environment-variable "PATH") @result{} "/usr/local/bin:/usr/bin:/bin" -@end example +@end lisp @end deffn @deffn {process-context library procedure} get-environment-variables @@ -118,10 +118,10 @@ of each entry is the name of an environment variable and the cdr is its value, b strings. The order of the list is unspecified. It is an error to mutate any of these strings or the alist itself. -@example +@lisp (get-environment-variables) @result{} (("USER" . "root") ("HOME" . "/")) -@end example +@end lisp @end deffn @deffn {time library procedure} current-second @@ -158,14 +158,14 @@ useful for accurate timing measurements. Returns an exact integer representing the number of jiffies per SI second. This value is an implementation-specified constant. -@example +@lisp (define (time-length) (let ((list (make-list 100000)) (start (current-jiffy))) (length list) (/ (- (current-jiffy) start) (jiffies-per-second)))) -@end example +@end lisp @end deffn @deffn procedure features @@ -173,12 +173,12 @@ an implementation-specified constant. Returns a list of the feature identifiers which cond-expand treats as true. It is an error to modify this list. Here is an example of what features might return: -@example +@lisp (features) @result{} (r7rs ratios exact-complex full-unicode gnu-linux little-endian fantastic-scheme fantastic-scheme-1.0 space-ship-control-system) -@end example +@end lisp @end deffn diff --git a/doc/r7rs-small/procedures/vectors.texinfo b/doc/r7rs-small/procedures/vectors.texinfo @@ -41,9 +41,9 @@ fill. Otherwise the initial contents of each element is unspecified. Returns a newly allocated vector whose elements contain the given arguments. It is analogous to list. -@example +@lisp (vector 'a 'b 'c) @result{} #(a b c) -@end example +@end lisp @end deffn @deffn procedure vector-length vector @@ -67,7 +67,7 @@ k of vector. -@example +@lisp (vector-ref '#(1 1 2 3 5 8 13 21) 5) @result{} 8 @@ -75,7 +75,7 @@ vector. (exact (round (* 2 (acos -1))))) @result{} 13 -@end example +@end lisp @end deffn @deffn procedure vector-set! vector k obj @@ -94,7 +94,7 @@ k of vector. -@example +@lisp (let ((vec (vector 0 '(2 2 2 2) "Anna"))) (vector-set! vec 1 '("Sue" "Sue")) vec) @@ -102,7 +102,7 @@ vector. (vector-set! '#(0 1 2) 1 "doe") @result{} error ; constant vector -@end example +@end lisp @end deffn @deffn procedure vector->list vector @@ -124,14 +124,14 @@ list. In both procedures, order is preserved. -@example +@lisp (vector->list '#(dah dah didah)) @result{} (dah dah didah) (vector->list '#(dah dah didah) 1 2) @result{} (dah) (list->vector '(dididit dah)) @result{} #(dididit dah) -@end example +@end lisp @end deffn @deffn procedure vector->string vector @@ -167,11 +167,11 @@ end. In both procedures, order is preserved. -@example +@lisp (string->vector "ABC") @result{} #(#\A #\B #\C) (vector->string #(#\1 #\2 #\3) @result{} "123" -@end example +@end lisp @end deffn @deffn procedure vector-copy vector @@ -187,14 +187,14 @@ start and end. The elements of the new vector are the same (in the sense of eqv?) as the elements of the old. -@example +@lisp (define a #(1 8 2 8)) ; a may be immutable (define b (vector-copy a)) (vector-set! b 0 3) ; b is mutable b @result{} #(3 8 2 8) (define c (vector-copy b 1 3)) c @result{} #(8 2) -@end example +@end lisp @end deffn @deffn procedure vector-copy! to at from @@ -230,12 +230,12 @@ destination overlap, copying takes place as if the source is first copied into a vector and then into the destination. This can be achieved without allocating storage by making sure to copy in the correct direction in such circumstances. -@example +@lisp (define a (vector 1 2 3 4 5)) (define b (vector 10 20 30 40 50)) (vector-copy! b 1 a 0 2) b @result{} #(10 1 2 40 50) -@end example +@end lisp @end deffn @deffn procedure vector-append vector@dots{} @@ -243,10 +243,10 @@ b @result{} #(10 1 2 40 50) Returns a newly allocated vector whose elements are the concatenation of the elements of the given vectors. -@example +@lisp (vector-append #(a b c) #(d e f)) @result{} #(a b c d e f) -@end example +@end lisp @end deffn @deffn procedure vector-fill! vector fill @@ -263,10 +263,10 @@ start and end. -@example +@lisp (define a (vector 1 2 3 4 5)) (vector-fill! a 'smash 2 4) a @result{} #(1 2 smash smash 5) -@end example +@end lisp @end deffn diff --git a/doc/r7rs-small/program-structure.texinfo b/doc/r7rs-small/program-structure.texinfo @@ -52,9 +52,9 @@ to its location in the file system. An import declaration takes the following form: -@example +@lisp (import @r{@svar{import-set} @dots{}}) -@end example +@end lisp An import declaration provides a way to import identifiers exported by a library. Each @svar{import set} names a set of bindings from a library and @@ -136,20 +136,20 @@ takes one of the following forms: sequence of one or more variables followed by a space-delimited period and another variable (as in a lambda expression). This form is equivalent to -@example +@lisp (define @r{@svar{variable}} (lambda (@r{@svar{formals}}) @r{@svar{body}}))@r{.} -@end example +@end lisp @item @code{(define (}@svar{variable} @code{.} @svar{formal}@code{)} @svar{body}@code{)} @svar{Formal} is a single variable. This form is equivalent to -@example +@lisp (define @r{@svar{variable}} (lambda @r{@svar{formal}} @r{@svar{body}}))@r{.} -@end example +@end lisp @end itemize @@ -164,16 +164,16 @@ another variable (as in a lambda expression). This form is equivalent to At the outermost level of a program, a definition -@example +@lisp (define @r{@svar{variable} @svar{expression}}) -@end example +@end lisp has essentially the same effect as the assignment expression -@example +@lisp (set! @r{@svar{variable} @svar{expression}}) -@end example +@end lisp if @svar{variable} is bound to a non-syntax value. However, if @svar{variable} is not bound, or is a syntactic keyword, then the @@ -181,13 +181,13 @@ definition will bind @svar{variable} to a new location before performing the assignment, whereas it would be an error to perform a @code{set!} on an unbound variable. -@example +@lisp (define add3 (lambda (x) (+ x 3))) (add3 3) @result{} 6 (define first car) (first '(1 2)) @result{} 1 -@end example +@end lisp @node Internal definitions @subsection Internal definitions @@ -203,23 +203,23 @@ above. The variables defined by internal definitions are local to the @svar{body}. That is, @svar{variable} is bound rather than assigned, and the region of the binding is the entire @svar{body}. For example, -@example +@lisp (let ((x 5)) (define foo (lambda (y) (bar x y))) (define bar (lambda (a b) (+ (* a b) a))) (foo (+ x 3))) @result{} 45 -@end example +@end lisp An expanded @svar{body} containing internal definitions can always be converted into a completely equivalent @code{letrec*} expression. For example, the @code{let} expression in the above example is equivalent to -@example +@lisp (let ((x 5)) (letrec* ((foo (lambda (y) (bar x y))) (bar (lambda (a b) (+ (* a b) a)))) (foo (+ x 3)))) -@end example +@end lisp Just as for the equivalent @code{letrec*} expression, it is an error if it is not possible to evaluate each @svar{expression} of every internal @@ -250,14 +250,14 @@ Semantics: @svar{Expression} is evaluated, and the @svar{formals} are bound to the return values in the same way that the @svar{formals} in a @code{lambda} expression are matched to the arguments in a procedure call. -@example +@lisp (define-values (x y) (exact-integer-sqrt 17)) (list x y) @result{} (4 1) (let () (define-values (x y) (values 1 2)) (+ x y)) @result{} 3 -@end example +@end lisp @end deffn @@ -266,9 +266,9 @@ bound to the return values in the same way that the @svar{formals} in a Syntax definitions have this form: -@example +@lisp (define-syntax @r{@svar{keyword} @svar{transformer spec}}) -@end example +@end lisp @svar{Keyword} is an identifier, and the @svar{transformer spec} is an instance of @code{syntax-rules}. Like variable definitions, syntax @@ -283,7 +283,7 @@ defined. Any use of a syntax keyword before its corresponding definition is an error. In particular, a use that precedes an inner definition will not apply an outer definition. -@example +@lisp (let ((x 1) (y 2)) (define-syntax swap! (syntax-rules () @@ -293,7 +293,7 @@ not apply an outer definition. (set! b tmp))))) (swap! x y) (list x y)) @result{} (2 1) -@end example +@end lisp Macros can expand into definitions in any context that permits them. However, it is an error for a definition to define an identifier @@ -305,7 +305,7 @@ in order to determine the boundary between the internal definitions and the expressions of the body it belongs to. For example, the following are errors: -@example +@lisp (define define 3) (begin (define begin list)) @@ -320,7 +320,7 @@ are errors: (foo (plus x y) (+ x y)) (define foo x) (plus foo x))) -@end example +@end lisp @node Record type definitions @section Record-type definitions @@ -404,19 +404,19 @@ type. For instance, the following record-type definition -@example +@lisp (define-record-type @svar{pare} (kons x y) pare? (x kar set-kar!) (y kdr)) -@end example +@end lisp defines @code{kons} to be a constructor, @code{kar} and @code{kdr} to be accessors, @code{set-kar!} to be a modifier, and @code{pare?} to be a predicate for instances of @code{<pare>}. -@example +@lisp (pare? (kons 1 2)) @result{} #t (pare? (cons 1 2)) @result{} #f (kar (kons 1 2)) @result{} 1 @@ -424,7 +424,7 @@ to be a predicate for instances of @code{<pare>}. (let ((k (kons 1 2))) (set-kar! k 3) (kar k)) @result{} 3 -@end example +@end lisp @end deffn @@ -572,7 +572,7 @@ The following example shows how a program can be divided into libraries plus a relatively small main program [16]. If the main program is entered into a REPL, it is not necessary to import the base library. -@example +@lisp (define-library (example grid) (export make rows cols ref each (rename put! set!)) @@ -660,7 +660,7 @@ into a REPL, it is not necessary to import the base library. ;; Run for 80 iterations. (life grid 80) -@end example +@end lisp @node The REPL @section The REPL diff --git a/doc/r7rs-small/scheme-example.texinfo b/doc/r7rs-small/scheme-example.texinfo @@ -15,7 +15,7 @@ length of the integration step. The value returned by integrate-system is an infinite stream of system states. -@example +@lisp (define (integrate-system system-derivative initial-state h) @@ -25,13 +25,13 @@ The value returned by integrate-system is an infinite stream of system states. (delay (map-streams next states))))) states))) -@end example +@end lisp The procedure runge-kutta-4 takes a function, f, that produces a system derivative from a system state. It produces a function that takes a system state and produces a new system state. -@example +@lisp (define (runge-kutta-4 f h) (let ((*h (scale-vector h)) (*2 (scale-vector 2)) @@ -72,27 +72,27 @@ produces a new system state. (define (scale-vector s) (elementwise (lambda (x) (* x s)))) -@end example +@end lisp The map-streams procedure is analogous to map: it applies its first argument (a procedure) to all the elements of its second argument (a stream). -@example +@lisp (define (map-streams f s) (cons (f (head s)) (delay (map-streams f (tail s))))) -@end example +@end lisp Infinite streams are implemented as pairs whose car holds the first element of the stream and whose cdr holds a promise to deliver the rest of the stream. -@example +@lisp (define head car) (define (tail stream) (force (cdr stream))) -@end example +@end lisp The following illustrates the use of integrate-system in integrating the system @@ -106,7 +106,7 @@ The following illustrates the use of integrate-system in integrating the system which models a damped oscillator. -@example +@lisp (define (damped-oscillator R L C) (lambda (state) (let ((Vc (vector-ref state 0)) @@ -119,4 +119,4 @@ which models a damped oscillator. (damped-oscillator 10000 1000 .001) '#(1 0) .01)) -@end example +@end lisp