/usr/lib/s9fes/while.scm is in scheme9 2010.11.13-2.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 | ; Scheme 9 from Empty Space, Function Library
; By Nils M Holm, 2010
; See the LICENSE file of the S9fES package for terms of use
;
; (until <test-expression> <body>) ==> unspecific
; (while <test-expression> <body>) ==> unspecific
;
; (load-from-library "while.scm")
;
; The WHILE form first evaluates <test-expression>. When it evaluates
; to a true value, it also evaluates <body>, which is a sequence of
; expressions. The expressions will be evaluated in order and then the
; WHILE form will be re-entered by evaluating <test-expression> once
; again. Then WHILE form terminates only if the test expression returns
; #F. The value of he form is unspecific.
;
; UNTIL is like WHILE, but evaluates its <body> until <test-expression>
; evaluates to truth.
;
; Example: (let ((x 0)
; (y 1))
; (while (< x 10)
; (set! y (* 2 y))
; (set! x (+ 1 x)))
; y) ==> 1024
(load-from-library "when.scm")
(define-syntax (while p . body)
(let ((loop (gensym)))
`(letrec ((,loop (lambda ()
(when ,p ,@body (,loop)))))
(,loop))))
(define-syntax (until p . body)
(let ((loop (gensym)))
`(letrec ((,loop (lambda ()
(unless ,p ,@body (,loop)))))
(,loop))))
|