Wiki
Download
Manual
Eggs
API
Tests
Bugs
show
edit
history
You can edit this page using
wiki syntax
for markup.
Article contents:
== srfi-216 [[toc:]] === Introduction This egg implements [[https://srfi.schemers.org/srfi-216/srfi-216.html|SRFI-216]], with minor modifications to the reference implementation to avoid unnecessary dependencies. === Author Vasilij Schneidermann === Repository [[https://depp.brause.cc/srfi-216]] === API ==== Booleans <constant>false</constant> 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. <constant>true</constant> 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 empty list <constant>nil</constant> 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. ==== Time data <procedure>(runtime)</procedure> 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. Example: <enscript highlight="scheme"> (import (srfi 216)) (display (runtime)) ;; prints 1604464095599.357 </enscript> ==== Random numbers <procedure>(random x)</procedure> 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. Example: <enscript highlight="scheme"> (import (srfi 216)) (random 11) ;; prints 1 </enscript> ==== Multi-threading <procedure>(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". Example: <enscript highlight="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. </enscript> <procedure>(test-and-set! cell)</procedure> Tests the cell and returns the result of the test. In addition, if the test was false, {{test-and-set!}} sets the cell contents to {{true}} before returning {{false}}. 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". ==== Streams <syntax>(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 [[/eggref/5/srfi-41|SRFI 41]] (implementing "even" streams) would not be a drop-in replacement for {{cons-stream}}. <constant>the-empty-stream</constant> 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. <procedure>(stream-null? x)</procedure> Returns the value of {{true}} if {{x}} is {{the-empty-stream}}, and the value of {{false}} otherwise. See SICP Section 3.5.1, footnote 54. Example: <enscript highlight="scheme"> (import (srfi 126)) (stream-null? the-empty-stream) ;; => #t (stream-null? (cons-stream 'a 'b)) ;; => #f </enscript> Equivalent to {{null?}}. === Example <enscript highlight="scheme"> (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)) </enscript> === License [[https://depp.brause.cc/srfi-216/LICENSES/MIT.txt|MIT]] === Version history ==== 0.1 * Initial release
Description of your changes:
I would like to authenticate
Authentication
Username:
Password:
Spam control
What do you get when you add 22 to 14?