1
Fork 0
mirror of https://git.savannah.gnu.org/git/guile.git synced 2025-05-23 21:10:29 +02:00

(SRFI-31): document.

This commit is contained in:
Rob Browning 2004-02-01 21:41:56 +00:00
parent e25853106e
commit 447e692283

View file

@ -28,6 +28,7 @@ get the relevant SRFI documents from the SRFI home page
* SRFI-16:: case-lambda * SRFI-16:: case-lambda
* SRFI-17:: Generalized set! * SRFI-17:: Generalized set!
* SRFI-19:: Time/Date library. * SRFI-19:: Time/Date library.
* SRFI-31:: A special form `rec' for recursive evaluation.
@end menu @end menu
@ -2397,3 +2398,36 @@ is expressed in @code{time-duration} values.
@end example @end example
@c srfi-modules.texi ends here @c srfi-modules.texi ends here
@node SRFI-31
@section SRFI-31 - A special form `rec' for recursive evaluation
SRFI-31 defines a special form that can be used to create
self-referential expressions more conveniently. The syntax is as
follows:
@example
@group
<rec expression> --> (rec <variable> <expression>)
<rec expression> --> (rec (<variable>+) <body>)
@end group
@end example
The first syntax can be used to create self-referential expressions,
for example:
@lisp
guile> (define tmp (rec ones (cons 1 (delay ones))))
@end lisp
The second syntax can be used to create anonymous recursive functions:
@lisp
guile> (define tmp (rec (display-n item n)
(if (positive? n)
(begin (display n) (display-n (- n 1))))))
guile> (tmp 42 3)
424242
guile>
@end lisp