This egg implements SRFI-216, with minor modifications to the reference implementation to avoid unnecessary dependencies.
The canonical false value #f.
Even though Scheme reports as early as R4RS (Sections 3.2, 6.1) already have #f as a distinct false value, SICP continues to refer to false. See Section 1.1.6, footnote 17.
The canonical true value #t.
Even though Scheme reports as early as R4RS (Sections 3.2, 6.1) already have #t as a distinct true value, SICP continues to refer to true. See Section 1.1.6, footnote 17.
The canonical empty list value '()
Remark: even though many modern Scheme implementations only use '() to represent the empty list, SICP follows the Lisp tradition in this respect.
Returns an integer that specifies the amount of time the process has been running (measured in microseconds). See Section 1.2.6 of the SICP, Subsection "Probabilistic Methods", Exercise 1.22.
(import (srfi 216)) (display (runtime)) ;; prints 1604464095599.357
- random xprocedure
Returns a nonnegative number less than its input. If random is given an exact integer, it returns an exact integer, but if it is given a decimal value, it returns a decimal value. If x is less than 0, the behaviour is unspecified. See Section 1.2.6 of the SICP, Subsection "Fermat Test", and Exercise 3.5, footnote 8.
(import (srfi 216)) (random 11) ;; prints 1
- parallel-execute p1 p2 ...procedure
Each argument must be a procedure of no arguments. parallel-execute creates a separate process for each argument, and that process applies the argument to no arguments. These processes all run concurrently.
See SICP Section 3.4.2, Subsection "Serializers in Scheme".
(import (srfi 216)) (define x 10) (parallel-execute (lambda () (set! x (* x x))) ; P1 (lambda () (set! x (+ x 1)))) ; P2 ;; May assign to x any of the following: ;; 101 - P1 sets x to 100 and then P2 increments x to 101. ;; 121 - P2 increments x to 11 and then P1 sets x to x * x. ;; 110 - P2 changes x from 10 to 11 between the two times that P1 accesses the value of x during the evaluation of (* x x). ;; 11 - P2 accesses x, then P1 sets x to 100, then P2 sets x. ;; 100 - P1 accesses x (twice), then P2 sets x to 11, then P 1 sets x.
- test-and-set! cellprocedure
The test-and-set! operation must be performed atomically. That is, the implementation must guarantee that, once a process has tested the cell and found it to be false, the cell contents will actually be set to true before any other process can test the cell. See Section 3.4.2, Subsection "Implementing Serializers".
- (cons-stream a b)syntax
Is equivalent to (cons a (delay b)). See SICP Section 3.5.1.
Remark: The necessity to include cons-stream is due to the fact that SICP does not introduce any syntax-altering constructs beyond writing your own metacircular interpreter. Please note that the stream-cons procedure from SRFI 41 (implementing "even" streams) would not be a drop-in replacement for cons-stream.
A distinguishable object that cannot be the result of any cons-stream operation. See SICP Section 3.5.1, footnote 54.
Equivalent to the empty list.
- stream-null? xprocedure
(import (srfi 126)) (stream-null? the-empty-stream) ;; => #t (stream-null? (cons-stream 'a 'b)) ;; => #f
Equivalent to null?.
(import scheme) (import (srfi 216)) (define (prime? n) ...) (define (timed-prime-test n) (newline) (display n) (start-prime-test n (runtime))) (define (start-prime-test n start-time) (if (prime? n) (report-prime (- (runtime) start-time)))) (define (report-prime elapsed-time) (display " *** ") (display elapsed-time))
- Initial release