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 63f6ad27b398ce1a2331039444230acc53358865
parent 98f7a00517fdd061bcca375c062e5523e84572c5
Author: Wolfgang Corcoran-Mathe <wcm@sigwinch.xyz>
Date:   Sun,  4 Feb 2024 21:39:16 -0500

Control features: Tidy examples.

Diffstat:
Mdoc/r7rs-small/procedures/control-features.texinfo | 68+++++++++++++++++++++++++++++++++-----------------------------------
1 file changed, 33 insertions(+), 35 deletions(-)

diff --git a/doc/r7rs-small/procedures/control-features.texinfo b/doc/r7rs-small/procedures/control-features.texinfo @@ -12,14 +12,14 @@ Returns @code{#t} if @var{obj} is a procedure, otherwise returns @code{#f}. @lisp -(procedure? car) @result{} #t -(procedure? 'car) @result{} #f +(procedure? car) @result{} #t +(procedure? 'car) @result{} #f (procedure? (lambda (x) (* x x))) - @result{} #t + @result{} #t (procedure? '(lambda (x) (* x x))) - @result{} #f + @result{} #f (call-with-current-continuation procedure?) - @result{} #t + @result{} #t @end lisp @end deffn @@ -30,14 +30,14 @@ The @code{apply} procedure calls @var{proc} with the elements of the list @code{(append (list }@vari{arg} @dots{}@code{) args)} as the actual arguments. @lisp -(apply + (list 3 4)) @result{} 7 +(apply + (list 3 4)) @result{} 7 (define compose (lambda (f g) (lambda args (f (apply g args))))) -((compose sqrt *) 12 75) @result{} 30 +((compose sqrt *) 12 75) @result{} 30 @end lisp @end deffn @@ -59,22 +59,20 @@ The dynamic order in which @var{proc} is applied to the elements of the the values returned by earlier returns are not mutated. @lisp -(map cadr '((a b) (d e) (g h))) -@result{} (b e h) +(map cadr '((a b) (d e) (g h))) @result{} (b e h) (map (lambda (n) (expt n n)) '(1 2 3 4 5)) -@result{} (1 4 27 256 3125) + @result{} (1 4 27 256 3125) -(map + '(1 2 3) '(4 5 6 7)) @result{} (5 7 9) +(map + '(1 2 3) '(4 5 6 7)) @result{} (5 7 9) (let ((count 0)) (map (lambda (ignored) (set! count (+ count 1)) count) - '(a b))) @result{} (1 2) - -or (2 1) + '(a b))) + @result{} (1 2) @r{or} (2 1) @end lisp @end deffn @@ -95,14 +93,13 @@ If multiple returns occur from @code{string-map}, the values returned by earlier returns are not mutated. @lisp -(string-map char-foldcase "AbdEgH") -@result{} "abdegh" +(string-map char-foldcase "AbdEgH") @result{} "abdegh" (string-map (lambda (c) (integer->char (+ 1 (char->integer c)))) "HAL") -@result{} "IBM" + @result{} "IBM" (string-map (lambda (c k) @@ -110,7 +107,7 @@ the values returned by earlier returns are not mutated. c)) "studlycaps xxx" "ululululul") -@result{} "StUdLyCaPs" + @result{} "StUdLyCaPs" @end lisp @end deffn @@ -131,24 +128,21 @@ If multiple returns occur from @code{vector-map}, the values returned by earlier returns are not mutated. @lisp -(vector-map cadr '#((a b) (d e) (g h))) -@result{} #(b e h) +(vector-map cadr '#((a b) (d e) (g h))) @result{} #(b e h) (vector-map (lambda (n) (expt n n)) '#(1 2 3 4 5)) -@result{} #(1 4 27 256 3125) + @result{} #(1 4 27 256 3125) -(vector-map + '#(1 2 3) '#(4 5 6 7)) -@result{} #(5 7 9) +(vector-map + '#(1 2 3) '#(4 5 6 7)) @result{} #(5 7 9) (let ((count 0)) (vector-map (lambda (ignored) (set! count (+ count 1)) count) - '#(a b))) @result{} #(1 2) - -or #(2 1) + '#(a b))) + @result{} #(1 2) @r{or} #(2 1) @end lisp @end deffn @@ -174,7 +168,8 @@ It is an error for @var{proc} to mutate any of the lists. (for-each (lambda (i) (vector-set! v i (* i i))) '(0 1 2 3 4)) - v) @result{} #(0 1 4 9 16) + v) + @result{} #(0 1 4 9 16) @end lisp @end deffn @@ -198,7 +193,8 @@ It is an error for @var{proc} to mutate any of the strings. (string-for-each (lambda (c) (set! v (cons (char->integer c) v))) "abcde") - v) @result{} (101 100 99 98 97) + v) + @result{} (101 100 99 98 97) @end lisp @end deffn @@ -223,7 +219,8 @@ It is an error for @var{proc} to mutate any of the vectors. (vector-for-each (lambda (i) (list-set! v i (* i i))) '#(0 1 2 3 4)) - v) @result{} (0 1 4 9 16) + v) + @result{} (0 1 4 9 16) @end lisp @end deffn @@ -281,7 +278,8 @@ the power of @code{call-with-current-continuation}. (if (negative? x) (exit x))) '(54 0 37 -3 245 19)) - #t)) @result{} -3 + #t)) + @result{} -3 (define list-length (lambda (obj) @@ -295,9 +293,9 @@ the power of @code{call-with-current-continuation}. (else (return #f)))))) (r obj)))))) -(list-length '(1 2 3 4)) @result{} 4 +(list-length '(1 2 3 4)) @result{} 4 -(list-length '(a b . c)) @result{} #f +(list-length '(a b . c)) @result{} #f @end lisp @subheading Rationale: @@ -351,9 +349,9 @@ continuation of the call to @code{call-with-values}. @lisp (call-with-values (lambda () (values 4 5)) (lambda (a b) b)) - @result{} 5 + @result{} 5 -(call-with-values * -) @result{} -1 +(call-with-values * -) @result{} -1 @end lisp @end deffn @@ -430,7 +428,7 @@ extent of a call to @var{before} or @var{after} is unspecified. (c 'talk2) (reverse path)))) -@result{} (connect talk1 disconnect + @result{} (connect talk1 disconnect connect talk2 disconnect) @end lisp