diff options
| author | 2021-06-26 13:57:57 -0700 | |
|---|---|---|
| committer | 2021-07-18 20:15:22 -0700 | |
| commit | 149caf47cb31d6effb4d1475c215336b8d545459 (patch) | |
| tree | 838c559a545746071c7a3be458c0494b575ed2b8 /srfi-225.html | |
| parent | Merge pull request #5 from arvyy/master (diff) | |
copy edits
Diffstat (limited to 'srfi-225.html')
| -rw-r--r-- | srfi-225.html | 18 |
1 files changed, 9 insertions, 9 deletions
diff --git a/srfi-225.html b/srfi-225.html index 0fd99cd..6cd3ecc 100644 --- a/srfi-225.html +++ b/srfi-225.html @@ -18,7 +18,7 @@ The procedures of this SRFI allow callers to manipulate an object that maps keys to values without the caller needing to know exactly what the type -of the object is. Such an object is called a *dictionary* in this SRFI. +of the object is. Such an object is called a <em>dictionary</em> in this SRFI. <h2 id="issues">Issues</h2> @@ -59,12 +59,12 @@ similar to an existing hash table.</p> <p><code>(dict-contains?</code> <em>dictionary key</em><code>)</code></p> <blockquote><pre>(dict-contains? dict 1) => #t (dict-contains? dict 2) => #f</code></blockquote> -<p>Returns <code>#t</code>if one of the keys of <em>dictionary</em> is the same as <em>key</em> and <code>#f</code> otherwise.</p> +<p>Returns <code>#t</code> if one of the keys of <em>dictionary</em> is the same as <em>key</em>, and <code>#f</code> otherwise.</p> <h3 id="lookup">Lookup</h3> <p><code>(dict-ref</code> <em>dictionary key</em> [<em>failure</em> [<em>success</em>] ]<code>)</code></p> <p>If <em>key</em> is the same as some key of <em>dictionary</em>, then invokes <em>success</em> on the corresponding value and returns its result. If <em>key</em> is not a key of <em>dictionary</em>, then invokes the thunk <em>failure</em> and returns its result. The default value of <em>failure</em> signals an error; the default value of <em>success</em> is the identity procedure.</p> -<blockquote><pre>(dict-ref dict 1 (lambda () '() list) => (1) ; success wraps value in a list -(dict-ref dict 2 (lambda () '() list)) => () ; failure returns empty list</code></blockquote> +<blockquote><pre>(dict-ref dict 1 (lambda () '()) list) => (1) ; Success wraps value in a list +(dict-ref dict 2 (lambda () '()) list) => () ; Failure returns empty list</code></blockquote> <p><code>(dict-ref/default</code> <em>dictionary key default</em><code>)</code></p> <p>If <em>key</em> is the same as some key of <em>dictionary</em> then returns the corresponding value. If not, then returns <em>default</em>.</p> <blockquote><pre>(dict-ref/default dict 1 #f) => 1 @@ -191,15 +191,15 @@ one for each of the four continuations: ; writes "135" to current output</code></blockquote> <p><code>(dict-count</code> <em>pred dictionary</em><code>)</code></p> <p>Passes each association of dictionary as two arguments to <em>pred</em> and returns the number of times that <em>pred</em> returned true as an an exact integer.</p> -<blockquote><pre>(dict-count dict (lambda (k v) (even? k) => 0</code></blockquote> +<blockquote><pre>(dict-count dict (lambda (k v) (even? k))) => 0</code></blockquote> <p><code>(dict-any</code> <em>pred dictionary</em><code>)</code></p> <p>Passes each association of <em>dictionary</em> as two arguments to <em>pred</em> and returns the value of the first call to <em>pred</em> that returns true, after which no further calls are made. If the dictionary type is inherently ordered, associations are processed in the inherent order; otherwise in an arbitrary order. If all calls return false, <code>dict-any</code> returns false.</p> -<blockquote><pre>(define (both-even? k v) (and (even? k) (even? v)) +<blockquote><pre>(define (both-even? k v) (and (even? k) (even? v))) (dict-any both-even? '((2 . 4) (3 . 5))) => #t (dict-any both-even? '((1 . 2) (3 . 4))) => #f</code></blockquote> <p><code>(dict-every</code> <em>pred dictionary</em><code>)</code></p> -<p>Passes each association of <em>dictionary</em> as two arguments to <em>pred</em> and returns <code>#f</code> after the first call to <em>pred</em> that returns false after which no further calls are made. If the dictionary type is inherently ordered, associations are processed in the inherent order; otherwise in an arbitrary order. If all calls return true, <code>dict-any</code> returns the value of the last call, or <code>#t</code> if no calls are made.</p> -<blockquote><pre>(define (some-even? k v) (or (even? k) (even? v)) +<p>Passes each association of <em>dictionary</em> as two arguments to <em>pred</em> and returns <code>#f</code> after the first call to <em>pred</em> that returns false, after which no further calls are made. If the dictionary type is inherently ordered, associations are processed in the inherent order; otherwise in an arbitrary order. If all calls return true, <code>dict-any</code> returns the value of the last call, or <code>#t</code> if no calls are made.</p> +<blockquote><pre>(define (some-even? k v) (or (even? k) (even? v))) (dict-every some-even? '((2 . 3) (3 . 4))) => #t (dict-every some-even? '((1 . 3) (3 . 4))) => #f</code></blockquote> <p><code>(dict-keys</code> <em>dictionary</em><code>)</code></p> @@ -209,7 +209,7 @@ one for each of the four continuations: <p>Returns a list of the values of <em>dictionary</em>. The results returned by <code>dict-keys</code> and <code>dict-values</code> are ordered consistently.</p> <blockquote><pre>(dict-values dict) => (2 4 6)</code></blockquote> <p><code>(dict-entries</code> <em>dictionary</em><code>)</code></p> -<p>Returns two values, the result of calling <code>dict-keys</code> and the result of calling <code>dict-values</code> on <em>dictionary</em>.</p> +<p>Returns two values, the results of calling <code>dict-keys</code> and the result of calling <code>dict-values</code> on <em>dictionary</em>.</p> <blockquote><pre>(dict-entries dict) => ; 2 values (1 3 5) (2 4 6)</code></blockquote> |
