Merge branch 'master' of git:plt

This commit is contained in:
Ryan Culpepper 2010-04-23 17:31:56 -06:00
commit 2434220fa5
64 changed files with 425 additions and 377 deletions

View File

@ -1,4 +1,4 @@
#lang scheme/base #lang racket/base
(provide get-general-acks (provide get-general-acks
get-translating-acks get-translating-acks

View File

@ -1,4 +1,4 @@
#lang scheme/base #lang racket/base
(require scheme/class (require scheme/class
scheme/math scheme/math

View File

@ -1,4 +1,4 @@
(module default-code-style mzscheme #lang racket/base
(provide color-default-code-styles (provide color-default-code-styles
bw-default-code-styles bw-default-code-styles
code-style-color code-style-color
@ -24,4 +24,4 @@
(list 'unbound-variable (make-code-style "red" #f #f #f)) (list 'unbound-variable (make-code-style "red" #f #f #f))
(list 'bound-variable (make-code-style "navy" #f #f #f)) (list 'bound-variable (make-code-style "navy" #f #f #f))
(list 'primitive (make-code-style "navy" #f #f #f)) (list 'primitive (make-code-style "navy" #f #f #f))
(list 'constant (make-code-style '(51 135 39) #f #f #f))))) (list 'constant (make-code-style '(51 135 39) #f #f #f))))

View File

@ -1,4 +1,4 @@
#lang scheme/base #lang racket/base
(require scheme/gui/base "private/key.ss") (require scheme/gui/base "private/key.ss")
(define debugging? (getenv "PLTDRDEBUG")) (define debugging? (getenv "PLTDRDEBUG"))

View File

@ -1,4 +1,4 @@
(module installer mzscheme #lang racket/base
(require mzlib/file (require mzlib/file
mzlib/etc mzlib/etc
launcher) launcher)
@ -18,4 +18,4 @@
(mred-program-launcher-path "DrScheme") (mred-program-launcher-path "DrScheme")
(cons (cons
`(exe-name . "DrScheme") `(exe-name . "DrScheme")
(build-aux-from-path (build-path (collection-path "drscheme") "drscheme"))))))) (build-aux-from-path (build-path (collection-path "drscheme") "drscheme"))))))

View File

@ -1,2 +1,2 @@
(module main scheme/base #lang racket/base
(require "drscheme.ss")) (require "drscheme.ss")

View File

@ -1,10 +1,8 @@
#lang scheme/unit #lang scheme/unit
(require mzlib/class (require racket/class
mzlib/list
scheme/file
string-constants string-constants
mred racket/gui/base
framework framework
browser/external browser/external
setup/getinfo setup/getinfo

View File

@ -1,4 +1,4 @@
#lang mzscheme #lang racket/base
#| #|
CODE COPIED (with permission ...) from syntax-browser.ss CODE COPIED (with permission ...) from syntax-browser.ss
@ -9,13 +9,10 @@ Marshalling (and hence the 'read' method of the snipclass omitted for fast proto
|# |#
(require mzlib/pretty (require racket/pretty
mzlib/list racket/class
mzlib/class racket/gui/base
mred racket/contract)
mzlib/match
mzlib/string
mzlib/contract)
(provide render-bindings/snip) (provide render-bindings/snip)
@ -64,7 +61,7 @@ Marshalling (and hence the 'read' method of the snipclass omitted for fast proto
; how to enrich the notion of an output-port to get 'bold'ing to ; how to enrich the notion of an output-port to get 'bold'ing to
; work otherwise... ; work otherwise...
(let* ([before (send output-text last-position)]) (let* ([before (send output-text last-position)])
(pretty-print (syntax-object->datum stx)) (pretty-print (syntax->datum stx))
(let* ([post-newline (send output-text last-position)]) (let* ([post-newline (send output-text last-position)])
(send output-text delete post-newline) ; delete the trailing \n. yuck! (send output-text delete post-newline) ; delete the trailing \n. yuck!
(send output-text insert " ") (send output-text insert " ")
@ -164,7 +161,7 @@ Marshalling (and hence the 'read' method of the snipclass omitted for fast proto
(define black-style-delta (make-object style-delta% 'change-normal-color)) (define black-style-delta (make-object style-delta% 'change-normal-color))
(define green-style-delta (make-object style-delta%)) (define green-style-delta (make-object style-delta%))
(send green-style-delta set-delta-foreground "forest green") (void (send green-style-delta set-delta-foreground "forest green"))
(define turn-snip% (define turn-snip%
(class snip% (class snip%

View File

@ -1,6 +1,6 @@
#lang scheme #lang racket/base
(require mred/mred) (require racket/gui/base racket/class)
(provide bitmap-message%) (provide bitmap-message%)
(define bitmap-message% (define bitmap-message%

View File

@ -1,4 +1,4 @@
#lang scheme/base #lang racket/base
#| #|
@ -10,11 +10,11 @@ profile todo:
(require errortrace/errortrace-key (require errortrace/errortrace-key
scheme/unit scheme/unit
scheme/contract racket/contract
errortrace/stacktrace errortrace/stacktrace
scheme/class racket/class
scheme/path racket/path
scheme/gui/base racket/gui/base
string-constants string-constants
framework framework
framework/private/bday framework/private/bday
@ -23,9 +23,9 @@ profile todo:
"bindings-browser.ss" "bindings-browser.ss"
net/sendurl net/sendurl
net/url net/url
scheme/match racket/match
mrlib/include-bitmap mrlib/include-bitmap
(for-syntax scheme/base)) (for-syntax racket/base))
(define orig (current-output-port)) (define orig (current-output-port))

View File

@ -1,12 +1,12 @@
#lang scheme/base #lang racket/base
(require mred (require mred
scheme/class racket/class
scheme/cmdline racket/cmdline
scheme/list racket/list
framework/private/bday framework/private/bday
framework/splash framework/splash
scheme/file racket/file
"eb.ss") "eb.ss")
(define files-to-open (command-line #:args filenames filenames)) (define files-to-open (command-line #:args filenames filenames))

View File

@ -1,4 +1,4 @@
#lang scheme/base #lang racket/base
(require scheme/unit) (require scheme/unit)
(provide drscheme:eval^ (provide drscheme:eval^

View File

@ -1,7 +1,7 @@
#lang scheme/base #lang racket/base
(require scheme/class (require racket/class
framework/splash framework/splash
scheme/gui/base) racket/gui/base)
(provide install-eb) (provide install-eb)
(define (install-eb) (define (install-eb)

View File

@ -1,6 +1,6 @@
#lang scheme/base #lang racket/base
(require scheme/class (require racket/class
scheme/gui/base) racket/gui/base)
(provide get-enclosing-editor-frame) (provide get-enclosing-editor-frame)

View File

@ -1,9 +1,9 @@
#lang mzscheme #lang racket/base
(require mred (require mred
mzlib/unit scheme/unit
mzlib/port racket/port
mzlib/class racket/class
syntax/toplevel syntax/toplevel
framework framework
"drsig.ss") "drsig.ss")
@ -11,7 +11,7 @@
;; to ensure this guy is loaded (and the snipclass installed) in the drscheme namespace & eventspace ;; to ensure this guy is loaded (and the snipclass installed) in the drscheme namespace & eventspace
;; these things are for effect only! ;; these things are for effect only!
(require mrlib/cache-image-snip (require mrlib/cache-image-snip
(prefix image-core: mrlib/image-core)) (prefix-in image-core: mrlib/image-core))
(define op (current-output-port)) (define op (current-output-port))
(define (oprintf . args) (apply fprintf op args)) (define (oprintf . args) (apply fprintf op args))
@ -173,7 +173,7 @@
(error-print-width 250) (error-print-width 250)
(current-ps-setup (make-object ps-setup%)) (current-ps-setup (make-object ps-setup%))
(current-namespace (make-namespace 'empty)) (current-namespace (make-empty-namespace))
(for-each (λ (x) (namespace-attach-module drscheme:init:system-namespace x)) (for-each (λ (x) (namespace-attach-module drscheme:init:system-namespace x))
to-be-copied-module-names)) to-be-copied-module-names))

View File

@ -1,8 +1,8 @@
#lang mzscheme #lang racket/base
(require mzlib/unit (require scheme/unit
mzlib/class racket/class
racket/gui/base
"drsig.ss" "drsig.ss"
mred
framework framework
string-constants) string-constants)

View File

@ -1,9 +1,8 @@
#lang scheme/unit #lang scheme/unit
(require string-constants (require string-constants
mzlib/match racket/match
mzlib/class racket/class
mzlib/string racket/string
mzlib/list
"drsig.ss" "drsig.ss"
mred mred
framework framework
@ -11,7 +10,7 @@
net/head net/head
setup/plt-installer setup/plt-installer
help/bug-report help/bug-report
scheme/file) racket/file)
(import [prefix drscheme:unit: drscheme:unit^] (import [prefix drscheme:unit: drscheme:unit^]
[prefix drscheme:app: drscheme:app^] [prefix drscheme:app: drscheme:app^]

View File

@ -1,6 +1,6 @@
#lang scheme/unit #lang scheme/unit
(require scheme/class (require racket/class
"drsig.ss") "drsig.ss")
(import [prefix drscheme:unit: drscheme:unit^] (import [prefix drscheme:unit: drscheme:unit^]

View File

@ -1,9 +1,9 @@
#lang scheme/unit #lang scheme/unit
(require scheme/gui/base (require racket/gui/base
browser/external browser/external
framework framework
scheme/class racket/class
net/url net/url
setup/dirs setup/dirs
help/search help/search

View File

@ -1,8 +1,8 @@
#lang scheme/base #lang racket/base
(provide draw-honu) (provide draw-honu)
(require scheme/class (require racket/class
scheme/gui/base racket/gui/base
"palaka.ss") "palaka.ss")
(define pi (atan 0 -1)) (define pi (atan 0 -1))

View File

@ -1,8 +1,7 @@
#lang scheme/unit #lang scheme/unit
(require string-constants (require string-constants
"drsig.ss" "drsig.ss"
mzlib/list racket/gui/base)
mred)
(import) (import)

View File

@ -2,7 +2,7 @@
(require typed/mred/mred (require typed/mred/mred
typed/framework/framework typed/framework/framework
scheme/class racket/class
string-constants/string-constant) string-constants/string-constant)

View File

@ -1,4 +1,4 @@
#lang mzscheme #lang racket/base
(provide break-threads) (provide break-threads)
(define super-cust (current-custodian)) (define super-cust (current-custodian))
(define first-child (make-custodian)) (define first-child (make-custodian))

View File

@ -1,28 +1,28 @@
#lang mzscheme #lang racket/base
(require mred (require racket/gui/base
mzlib/class) racket/class)
(provide (all-from-except mred frame%) (provide (except-out (all-from-out racket/gui/base) frame%)
(rename registering-frame% frame%) (rename-out [registering-frame% frame%])
lookup-frame-name) lookup-frame-name)
(define (lookup-frame-name frame) (define (lookup-frame-name frame)
(semaphore-wait label-sema) (semaphore-wait label-sema)
(begin0 (begin0
(hash-table-get label-ht frame (λ () #f)) (hash-ref label-ht frame (λ () #f))
(semaphore-post label-sema))) (semaphore-post label-sema)))
(define label-sema (make-semaphore 1)) (define label-sema (make-semaphore 1))
(define label-ht (make-hash-table 'weak)) (define label-ht (make-weak-hasheq))
(define registering-frame% (define registering-frame%
(class frame% (class frame%
(define/override (set-label x) (define/override (set-label x)
(semaphore-wait label-sema) (semaphore-wait label-sema)
(hash-table-put! label-ht this x) (hash-set! label-ht this x)
(semaphore-post label-sema) (semaphore-post label-sema)
(super set-label x)) (super set-label x))
(inherit get-label) (inherit get-label)
(super-instantiate ()) (super-instantiate ())
(semaphore-wait label-sema) (semaphore-wait label-sema)
(hash-table-put! label-ht this (get-label)) (hash-set! label-ht this (get-label))
(semaphore-post label-sema))) (semaphore-post label-sema)))

View File

@ -1,13 +1,13 @@
#lang scheme/base #lang racket/base
(require scheme/unit (require scheme/unit
mrlib/hierlist mrlib/hierlist
scheme/class racket/class
scheme/contract racket/contract
scheme/string racket/string
scheme/list racket/list
racket/gui/base
"drsig.ss" "drsig.ss"
string-constants string-constants
mred
framework framework
setup/getinfo setup/getinfo
syntax/toplevel syntax/toplevel
@ -1252,7 +1252,12 @@
(message-box (message-box
(string-constant drscheme) (string-constant drscheme)
(format (format
"The drscheme-language-position, drscheme-language-modules, drscheme-language-numbers, and drscheme-language-readers specifications aren't correct. Expected (listof (cons string (listof string))), (listof (listof string)), (listof (listof number)), (listof string), (listof string), and (listof module-spec) respectively, where the lengths of the outer lists are the same. Got ~e, ~e, ~e, ~e, ~e, and ~e" (string-append
"The drscheme-language-position, drscheme-language-modules, drscheme-language-numbers,"
" and drscheme-language-readers specifications aren't correct. Expected"
" (listof (cons string (listof string))), (listof (listof string)), (listof (listof number)), (listof string),"
" (listof string), and (listof module-spec) respectively, where the lengths of the outer lists are the same."
" Got ~e, ~e, ~e, ~e, ~e, and ~e")
lang-positions lang-positions
lang-modules lang-modules
numberss numberss
@ -1431,7 +1436,7 @@
(let ([words #f]) (let ([words #f])
(λ () (λ ()
(unless words (unless words
(set! words (text:get-completions/manuals '(scheme/base scheme/contract)))) (set! words (text:get-completions/manuals '(racket/base racket/contract))))
words))) words)))
(define get-all-manual-keywords (define get-all-manual-keywords

View File

@ -1,14 +1,14 @@
#reader scribble/reader #reader scribble/reader
#lang scheme/base #lang racket/base
(require (for-syntax scheme/base) (require (for-syntax racket/base)
scribble/srcdoc scribble/srcdoc
scheme/class racket/class
scheme/gui/base racket/gui/base
scheme/contract racket/contract
"recon.ss") "recon.ss")
(require/doc scheme/base scribble/manual) (require/doc racket/base scribble/manual)
(require (for-meta 2 scheme/base)) (require (for-meta 2 racket/base))
(provide language-object-abstraction) (provide language-object-abstraction)

View File

@ -9,17 +9,17 @@
;; NOTE: this module instantiates stacktrace itself, so we have ;; NOTE: this module instantiates stacktrace itself, so we have
;; to be careful to not mix that instantiation with the one ;; to be careful to not mix that instantiation with the one
;; drscheme/private/debug.ss does. errortrace-lib's is for the ;; drracket/private/debug.ss does. errortrace-lib's is for the
;; compilation handling, DrScheme's is for profiling and test coverage ;; compilation handling, DrScheme's is for profiling and test coverage
;; (which do not do compilation) ;; (which do not do compilation)
(prefix-in el: errortrace/errortrace-lib) (prefix-in el: errortrace/errortrace-lib)
mzlib/pconvert mzlib/pconvert
scheme/pretty racket/pretty
mzlib/struct mzlib/struct
scheme/class racket/class
scheme/file racket/file
scheme/list racket/list
compiler/embed compiler/embed
launcher launcher
mred mred

View File

@ -1,8 +1,8 @@
#lang scheme/base #lang racket/base
(provide startup) (provide startup)
(require scheme/file) (require racket/file)
(define (read-from-string s) (read (open-input-string s))) (define (read-from-string s) (read (open-input-string s)))

View File

@ -1,9 +1,9 @@
#lang scheme/base #lang racket/base
(require scheme/gui/base "launcher-bootstrap.ss") (require racket/gui/base "launcher-bootstrap.ss")
(current-namespace (make-gui-empty-namespace)) (current-namespace (make-gui-empty-namespace))
(namespace-require 'scheme/gui/base) (namespace-require 'racket/gui/base)
(namespace-require 'scheme/class) (namespace-require 'racket/class)
(startup) (startup)

View File

@ -1,8 +1,8 @@
#lang scheme/base #lang racket/base
(require "launcher-bootstrap.ss") (require "launcher-bootstrap.ss")
(current-namespace (make-base-empty-namespace)) (current-namespace (make-base-empty-namespace))
(namespace-require 'scheme/base) (namespace-require 'racket/base)
(startup) (startup)

View File

@ -1,4 +1,4 @@
#lang scheme/base #lang racket/base
(require scheme/unit (require scheme/unit
"modes.ss" "modes.ss"
"font.ss" "font.ss"

View File

@ -7,7 +7,7 @@
framework framework
mzlib/class mzlib/class
mzlib/list mzlib/list
scheme/path racket/path
browser/external browser/external
setup/plt-installer) setup/plt-installer)

View File

@ -1,7 +1,7 @@
#lang scheme/unit #lang scheme/unit
(require string-constants (require string-constants
mzlib/class racket/class
mzlib/list racket/list
framework framework
"drsig.ss") "drsig.ss")
@ -23,7 +23,7 @@
(define (not-a-language-language? l) (define (not-a-language-language? l)
(and (not (null? l)) (and (not (null? l))
(equal? (car (last-pair l)) (equal? (last l)
(string-constant no-language-chosen)))) (string-constant no-language-chosen))))
(define (add-initial-modes) (define (add-initial-modes)

View File

@ -1,7 +1,7 @@
#lang scheme/base #lang racket/base
(require mred (require mred
scheme/class racket/class
syntax/moddep syntax/moddep
syntax/toplevel syntax/toplevel
framework/framework framework/framework
@ -9,7 +9,7 @@
mrlib/graph mrlib/graph
"drsig.ss" "drsig.ss"
scheme/unit scheme/unit
scheme/async-channel racket/async-channel
setup/private/lib-roots) setup/private/lib-roots)
(define-struct req (filename key)) (define-struct req (filename key))

View File

@ -1,12 +1,12 @@
#lang scheme/base #lang racket/base
(provide module-language-tools@) (provide module-language-tools@)
(require mrlib/switchable-button (require mrlib/switchable-button
mrlib/bitmap-label mrlib/bitmap-label
scheme/contract racket/contract
framework framework
scheme/unit scheme/unit
scheme/class racket/class
scheme/gui/base racket/gui/base
"drsig.ss") "drsig.ss")
(define op (current-output-port)) (define op (current-output-port))

View File

@ -1,11 +1,11 @@
#lang scheme/base #lang racket/base
(provide module-language@) (provide module-language@)
(require scheme/unit (require scheme/unit
scheme/class racket/class
scheme/list racket/list
scheme/path racket/path
scheme/contract racket/contract
mred mred
compiler/embed compiler/embed
compiler/cm compiler/cm
@ -382,7 +382,7 @@
#:literal-expression #:literal-expression
(begin (begin
(parameterize ([current-namespace (make-base-empty-namespace)]) (parameterize ([current-namespace (make-base-empty-namespace)])
(namespace-require 'scheme/base) (namespace-require 'racket/base)
(compile (compile
`(namespace-require '',(string->symbol (path->string short-program-name)))))) `(namespace-require '',(string->symbol (path->string short-program-name))))))
#:cmdline '("-U" "--"))))) #:cmdline '("-U" "--")))))
@ -672,7 +672,7 @@
(raise-hopeless-syntax-error "bad syntax in name position of module" (raise-hopeless-syntax-error "bad syntax in name position of module"
stx name)) stx name))
(when filename (check-filename-matches filename name* stx)) (when filename (check-filename-matches filename name* stx))
(let* (;; rewrite the module to use the scheme/base version of `module' (let* (;; rewrite the module to use the racket/base version of `module'
[mod (datum->syntax #'here 'module mod)] [mod (datum->syntax #'here 'module mod)]
[expr (datum->syntax stx `(,mod ,name ,lang . ,body) stx stx)]) [expr (datum->syntax stx `(,mod ,name ,lang . ,body) stx stx)])
(values name lang expr))) (values name lang expr)))

View File

@ -2,8 +2,8 @@
(require framework (require framework
mzlib/class mzlib/class
mred mred
scheme/file racket/file
scheme/path racket/path
mzlib/thread mzlib/thread
mzlib/async-channel mzlib/async-channel
string-constants string-constants

View File

@ -1,6 +1,6 @@
#lang mzscheme #lang racket/base
(require mred (require mred
mzlib/class racket/class
framework) framework)
(provide snip-class) (provide snip-class)

View File

@ -1,5 +1,5 @@
#lang scheme/base #lang racket/base
(require scheme/class scheme/gui/base) (require racket/class racket/gui/base)
(provide draw-palaka palaka-pattern-size) (provide draw-palaka palaka-pattern-size)
(define scale 1) (define scale 1)

View File

@ -1,6 +1,6 @@
#lang scheme/base #lang racket/base
(require (for-syntax scheme/base) (require (for-syntax racket/base)
framework/framework) framework/framework)
(provide (rename-out [-preferences:get preferences:get]) (provide (rename-out [-preferences:get preferences:get])

View File

@ -1,6 +1,6 @@
#lang scheme/base #lang racket/base
(require scheme/gui/base (require racket/gui/base
scheme/class racket/class
profile/sampler profile/sampler
profile/render-text profile/render-text
profile/analyzer profile/analyzer

View File

@ -1,5 +1,5 @@
#lang scheme/base #lang racket/base
(require (for-syntax scheme/base)) (require (for-syntax racket/base))
(provide reconstitute) (provide reconstitute)
(begin-for-syntax (begin-for-syntax

View File

@ -1,4 +1,4 @@
#lang scheme/base #lang racket/base
#| #|
@ -20,15 +20,15 @@ TODO
;; user's io ports, to aid any debugging printouts. ;; user's io ports, to aid any debugging printouts.
;; (esp. useful when debugging the users's io) ;; (esp. useful when debugging the users's io)
(require scheme/class (require racket/class
scheme/path racket/path
scheme/pretty racket/pretty
scheme/unit scheme/unit
scheme/list racket/list
string-constants string-constants
setup/xref setup/xref
scheme/gui/base racket/gui/base
framework framework
browser/external browser/external
"drsig.ss" "drsig.ss"

View File

@ -1,7 +1,7 @@
#lang mzscheme #lang racket/base
(require mzlib/class (require racket/class
mzlib/pretty racket/pretty
mred) racket/gui/base)
(define head-size 40) (define head-size 40)
(define small-bitmap-factor 1/2) (define small-bitmap-factor 1/2)

View File

@ -1,9 +1,9 @@
#lang scheme/unit #lang scheme/unit
(require scheme/class (require racket/class
scheme/list racket/list
scheme/runtime-path racket/runtime-path
scheme/contract racket/contract
setup/getinfo setup/getinfo
mred mred
framework framework
@ -13,7 +13,7 @@
mrlib/switchable-button mrlib/switchable-button
string-constants) string-constants)
(require (for-syntax scheme/base scheme/match)) (require (for-syntax racket/base racket/match))
(import [prefix drscheme:frame: drscheme:frame^] (import [prefix drscheme:frame: drscheme:frame^]
[prefix drscheme:unit: drscheme:unit^] [prefix drscheme:unit: drscheme:unit^]

View File

@ -1,12 +1,12 @@
#lang scheme/base #lang racket/base
(require scheme/contract (require racket/contract
scheme/unit scheme/unit
scheme/class racket/class
scheme/path racket/path
scheme/port racket/port
scheme/list racket/list
scheme/gui/base racket/gui/base
string-constants string-constants
framework framework
(prefix-in tr: trace/stacktrace) (prefix-in tr: trace/stacktrace)

View File

@ -1,5 +1,4 @@
#reader scribble/reader #lang at-exp racket/base
#lang scheme/base
(require scribble/decode (require scribble/decode
scribble/manual) scribble/manual)

View File

@ -1,4 +1,4 @@
#lang scheme/base #lang racket/base
#| #|
closing: closing:
@ -11,12 +11,12 @@ module browser threading seems wrong.
|# |#
(require scheme/contract (require racket/contract
scheme/unit scheme/unit
scheme/class racket/class
scheme/path racket/path
scheme/port racket/port
scheme/list racket/list
string-constants string-constants
framework framework
mrlib/name-message mrlib/name-message

View File

@ -1,4 +1,4 @@
#lang scheme/base #lang racket/base
(require scheme/gui/base (require scheme/gui/base
framework framework
scheme/class) scheme/class)

View File

@ -1,4 +1,4 @@
#lang scheme/base #lang racket/base
(require scheme/class (require scheme/class
scheme/gui/base scheme/gui/base
string-constants/string-constant) string-constants/string-constant)

View File

@ -1,4 +1,4 @@
#lang scheme/base #lang racket/base
#| #|
Check Syntax separates two classes of identifiers, Check Syntax separates two classes of identifiers,

View File

@ -1,4 +1,4 @@
#lang at-exp scheme/base #lang at-exp racket/base
#| #|
@ -9,7 +9,7 @@ all of the names in the tools library, for use defining keybindings
|# |#
(require scheme/class (require scheme/class
scheme/gui/base scheme/gui/base
scheme/unit (except-in scheme/unit struct)
scheme/contract scheme/contract
scheme/class scheme/class

View File

@ -1,4 +1,5 @@
(module tool mzscheme #lang racket/base
(require "private/drsig.ss") (require "private/drsig.ss")
(provide drscheme:tool^ (provide drscheme:tool^
drscheme:tool-exports^)) drscheme:tool-exports^)

View File

@ -6,6 +6,7 @@
set-empty? set-count set-empty? set-count
set-member? set-add set-remove set-member? set-add set-remove
set-union set-intersect set-subtract set-union set-intersect set-subtract
set-subset?
set-map set-for-each set-map set-for-each
(rename-out [*in-set in-set]) (rename-out [*in-set in-set])
for/set for/seteq for/seteqv for/set for/seteq for/seteqv
@ -163,6 +164,18 @@
(for/fold ([set set]) ([set2 (in-list sets)]) (for/fold ([set set]) ([set2 (in-list sets)])
(set-subtract set set2))])) (set-subtract set set2))]))
(define (set-subset? set1 set2)
(unless (set? set1) (raise-type-error 'set-subset? "set" 0 set1 set2))
(unless (set? set2) (raise-type-error 'set-subset? "set" 1 set1 set2))
(let ([ht1 (set-ht set1)]
[ht2 (set-ht set2)])
(unless (and (eq? (hash-eq? ht1) (hash-eq? ht2))
(eq? (hash-eqv? ht1) (hash-eqv? ht2)))
(raise-mismatch-error 'set-subset? "second set's equivalence predicate is not the same as the first set: "
set2))
(for/and ([v (in-hash-keys ht2)])
(hash-ref ht1 v #f))))
(define (set-map set proc) (define (set-map set proc)
(unless (set? set) (raise-type-error 'set-map "set" 0 set proc)) (unless (set? set) (raise-type-error 'set-map "set" 0 set proc))
(unless (and (procedure? proc) (unless (and (procedure? proc)

View File

@ -519,7 +519,7 @@
(set! src-col (+ src-col (- (syntax-span c) 2))) (set! src-col (+ src-col (- (syntax-span c) 2)))
(set! src-col (+ src-col (- (syntax-column (vector-ref vec 0)) (set! src-col (+ src-col (- (syntax-column (vector-ref vec 0))
(syntax-column c) (syntax-column c)
1))))))) 1))))))
(when (struct? (syntax-e c)) (when (struct? (syntax-e c))
(out "#s" p-color) (out "#s" p-color)
(set! src-col (+ src-col 2))) (set! src-col (+ src-col 2)))
@ -599,7 +599,7 @@
p-color) p-color)
(set! src-col (+ src-col 1)) (set! src-col (+ src-col 1))
#; #;
(hash-set! next-col-map src-col dest-col))] (hash-set! next-col-map src-col dest-col)))]
[(box? (syntax-e c)) [(box? (syntax-e c))
(advance c init-line!) (advance c init-line!)
(let ([quote-depth (to-quoted "`" qq? quote-depth out color? inc-src-col)]) (let ([quote-depth (to-quoted "`" qq? quote-depth out color? inc-src-col)])
@ -700,7 +700,8 @@
(hash? s) (hash? s)
(graph-defn? s) (graph-defn? s)
(graph-reference? s) (graph-reference? s)
(struct-proxy? s)) (struct-proxy? s)
(and qq? (identifier? c)))
(gen-typeset c multi-line? prefix1 prefix suffix color? qq?) (gen-typeset c multi-line? prefix1 prefix suffix color? qq?)
(typeset-atom c (typeset-atom c
(letrec ([mk (letrec ([mk

View File

@ -217,8 +217,8 @@ category, which is @indexed-scheme['lu], @indexed-scheme['ll],
@indexed-scheme['cn].} @indexed-scheme['cn].}
@defproc[(make-known-char-range-list) @defproc[(make-known-char-range-list)
(listof (list/c nonnegative-integer? (listof (list/c exact-nonnegative-integer?
nonnegative-integer? exact-nonnegative-integer?
boolean?))]{ boolean?))]{
Produces a list of three-element lists, where each three-element list Produces a list of three-element lists, where each three-element list

View File

@ -108,7 +108,7 @@ used as an ephemeron key (see @secref["ephemerons"]).
@scheme[(string->symbol str)], but the resulting symbol is a new @scheme[(string->symbol str)], but the resulting symbol is a new
@tech{unreadable symbol}. Calling @scheme[string->unreadable-symbol] @tech{unreadable symbol}. Calling @scheme[string->unreadable-symbol]
twice with equivalent @scheme[str]s returns the same symbol, but twice with equivalent @scheme[str]s returns the same symbol, but
@scheme[read] never produces the symbol.} @scheme[read] never produces the symbol.
@examples[(string->unreadable-symbol "Apple") @examples[(string->unreadable-symbol "Apple")
(eq? 'a (string->unreadable-symbol "a")) (eq? 'a (string->unreadable-symbol "a"))

View File

@ -90,7 +90,7 @@
(provide exnraise Exn) (provide exnraise Exn)
(provide margin-note/ref (provide margin-note/ref
refalso moreref Guide guideintro guidesecref refalso moreref Guide guideintro guidealso guidesecref
HonuManual) HonuManual)
(define (margin-note/ref . s) (define (margin-note/ref . s)
@ -118,6 +118,10 @@
s s
(list "."))))) (list ".")))))
(define (guidealso tag)
(apply margin-note
(decode-content (append (list finger "See also " (guidesecref tag) " in " Guide ".")))))
(define Guide (define Guide
(other-manual '(lib "scribblings/guide/guide.scrbl"))) (other-manual '(lib "scribblings/guide/guide.scrbl")))

View File

@ -453,7 +453,7 @@ used.
@defproc[(log [z number?]) number?]{ Returns the natural logarithm of @defproc[(log [z number?]) number?]{ Returns the natural logarithm of
@scheme[z]. The result is normally inexact, but it is @scheme[z]. The result is normally inexact, but it is
@scheme[0] when @scheme[z] is an exact @scheme[1]. When @scheme[z] @scheme[0] when @scheme[z] is an exact @scheme[1]. When @scheme[z]
is exact @scheme[0], @exnraise[exn:fail:contract:divide-by-zero].} is exact @scheme[0], @exnraise[exn:fail:contract:divide-by-zero].
@mz-examples[(log (exp 1)) (log 2+3i) (log 1)]} @mz-examples[(log (exp 1)) (log 2+3i) (log 1)]}
@ -883,7 +883,7 @@ numbers}, which are also known as @deftech{flonums}. Flonum-specific
operations provide can better performance when used consistently, and operations provide can better performance when used consistently, and
they are as safe as generic operations like @scheme[+]. they are as safe as generic operations like @scheme[+].
@margin-note{See @guidesecref["fixnums+flonums"].} @guidealso["fixnums+flonums"]
@subsection{Flonum Arithmetic} @subsection{Flonum Arithmetic}
@ -1080,7 +1080,7 @@ Safe versions of @scheme[unsafe-fx=], @scheme[unsafe-fx<],
@note-lib[racket/math] @note-lib[racket/math]
@defthing[pi real]{ @defthing[pi real?]{
An approximation to the ratio of a circle's circumference to its An approximation to the ratio of a circle's circumference to its
diameter: @number->string[pi].} diameter: @number->string[pi].}

View File

@ -26,7 +26,7 @@
@(define-syntax (defc_r stx) @(define-syntax (defc_r stx)
(syntax-case stx () (syntax-case stx ()
[(_ x ... example) [(_ x ... example-arg)
(let ([xs (map syntax-e (syntax->list #'(x ...)))]) (let ([xs (map syntax-e (syntax->list #'(x ...)))])
(let ([name (string->symbol (let ([name (string->symbol
(string-append (string-append
@ -58,10 +58,25 @@
span))) span)))
(datum->syntax #'here c (datum->syntax #'here c
(list (syntax-source stx) 1 pos (add1 pos) 1))))] (list (syntax-source stx) 1 pos (add1 pos) 1))))]
[example (datum->syntax #'here (syntax->datum #'example))] [example (let ([ex #'example-arg])
(datum->syntax #f
(list
(datum->syntax #f
name
(vector (syntax-source ex)
(syntax-line ex)
(- (syntax-column ex) 2)
(- (syntax-position ex) 2)
1))
ex)
(vector (syntax-source ex)
(syntax-line ex)
(- (syntax-column ex) 3)
(- (syntax-position ex) 3)
(+ (syntax-span ex) 4))))]
[equiv equiv]) [equiv equiv])
#'(defproc (name [v contract]) any/c #'(defproc (name [v contract]) any/c
"Returns " (to-element 'equiv) (mz-examples (name example))))))])) "Returns " (to-element 'equiv) (mz-examples example)))))]))
@title[#:tag "pairs"]{Pairs and Lists} @title[#:tag "pairs"]{Pairs and Lists}

View File

@ -22,13 +22,13 @@ matching character streams; if a byte regexp is used with a character
string, it matches bytes in the UTF-8 encoding of the string. string, it matches bytes in the UTF-8 encoding of the string.
Regular expressions can be compiled into a @deftech{regexp value} for Regular expressions can be compiled into a @deftech{regexp value} for
repeated matches. The @scheme[regexp] and @scheme[byte-regexp] repeated matches. The @racket[regexp] and @racket[byte-regexp]
procedures convert a string or byte string (respectively) into a procedures convert a string or byte string (respectively) into a
regexp value using one syntax of regular expressions that is most regexp value using one syntax of regular expressions that is most
compatible to @exec{egrep}. The @scheme[pregexp] and compatible to @exec{egrep}. The @racket[pregexp] and
@scheme[byte-pregexp] procedures produce a regexp value using a @racket[byte-pregexp] procedures produce a regexp value using a
slightly different syntax of regular expressions that is more slightly different syntax of regular expressions that is more
compatible with Perl. In addition, Scheme constants written with compatible with Perl. In addition, Racket constants written with
@litchar{#rx} or @litchar{#px} (see @secref["reader"]) produce @litchar{#rx} or @litchar{#px} (see @secref["reader"]) produce
compiled regexp values. compiled regexp values.
@ -43,22 +43,22 @@ The following syntax specifications describe the content of a string
that represents a regular expression. The syntax of the corresponding that represents a regular expression. The syntax of the corresponding
string may involve extra escape characters. For example, the regular string may involve extra escape characters. For example, the regular
expression @litchar{(.*)\1} can be represented with the string expression @litchar{(.*)\1} can be represented with the string
@scheme["(.*)\\1"] or the regexp constant @scheme[#rx"(.*)\\1"]; the @racket["(.*)\\1"] or the regexp constant @racket[#rx"(.*)\\1"]; the
@litchar{\} in the regular expression must be escaped to include it @litchar{\} in the regular expression must be escaped to include it
in a string or regexp constant. in a string or regexp constant.
The @scheme[regexp] and @scheme[pregexp] syntaxes share a common core: The @racket[regexp] and @racket[pregexp] syntaxes share a common core:
@common-table @common-table
The following completes the grammar for @scheme[regexp], which treats The following completes the grammar for @racket[regexp], which treats
@litchar["{"] and @litchar["}"] as literals, @litchar{\} as a @litchar["{"] and @litchar["}"] as literals, @litchar{\} as a
literal within ranges, and @litchar{\} as a literal producer literal within ranges, and @litchar{\} as a literal producer
outside of ranges. outside of ranges.
@rx-table @rx-table
The following completes the grammar for @scheme[pregexp], which uses The following completes the grammar for @racket[pregexp], which uses
@litchar["{"] and @litchar["}"] bounded repetition and uses @litchar["{"] and @litchar["}"] bounded repetition and uses
@litchar{\} for meta-characters both inside and outside of ranges. @litchar{\} for meta-characters both inside and outside of ranges.
@ -101,26 +101,26 @@ arbitrarily large sequence).
@defproc[(regexp? [v any/c]) boolean?]{ @defproc[(regexp? [v any/c]) boolean?]{
Returns @scheme[#t] if @scheme[v] is a @tech{regexp value} created by Returns @racket[#t] if @racket[v] is a @tech{regexp value} created by
@scheme[regexp] or @scheme[pregexp], @scheme[#f] otherwise.} @racket[regexp] or @racket[pregexp], @racket[#f] otherwise.}
@defproc[(pregexp? [v any/c]) boolean?]{ @defproc[(pregexp? [v any/c]) boolean?]{
Returns @scheme[#t] if @scheme[v] is a @tech{regexp value} created by Returns @racket[#t] if @racket[v] is a @tech{regexp value} created by
@scheme[pregexp] (not @scheme[regexp]), @scheme[#f] otherwise.} @racket[pregexp] (not @racket[regexp]), @racket[#f] otherwise.}
@defproc[(byte-regexp? [v any/c]) boolean?]{ @defproc[(byte-regexp? [v any/c]) boolean?]{
Returns @scheme[#t] if @scheme[v] is a @tech{regexp value} created by Returns @racket[#t] if @racket[v] is a @tech{regexp value} created by
@scheme[byte-regexp] or @scheme[byte-pregexp], @scheme[#f] otherwise.} @racket[byte-regexp] or @racket[byte-pregexp], @racket[#f] otherwise.}
@defproc[(byte-pregexp? [v any/c]) boolean?]{ @defproc[(byte-pregexp? [v any/c]) boolean?]{
Returns @scheme[#t] if @scheme[v] is a @tech{regexp value} created by Returns @racket[#t] if @racket[v] is a @tech{regexp value} created by
@scheme[byte-pregexp] (not @scheme[byte-regexp]), @scheme[#f] @racket[byte-pregexp] (not @racket[byte-regexp]), @racket[#f]
otherwise.} otherwise.}
@ -134,7 +134,7 @@ is used multiple times, it is faster to compile the string once to a
@tech{regexp value} and use it for repeated matches instead of using the @tech{regexp value} and use it for repeated matches instead of using the
string each time. string each time.
The @scheme[object-name] procedure returns The @racket[object-name] procedure returns
the source string for a @tech{regexp value}. the source string for a @tech{regexp value}.
@examples[ @examples[
@ -144,10 +144,10 @@ the source string for a @tech{regexp value}.
@defproc[(pregexp [string string?]) pregexp?]{ @defproc[(pregexp [string string?]) pregexp?]{
Like @scheme[regexp], except that it uses a slightly different syntax Like @racket[regexp], except that it uses a slightly different syntax
(see @secref["regexp-syntax"]). The result can be used with (see @secref["regexp-syntax"]). The result can be used with
@scheme[regexp-match], etc., just like the result from @racket[regexp-match], etc., just like the result from
@scheme[regexp]. @racket[regexp].
@examples[ @examples[
(pregexp "ap*le") (pregexp "ap*le")
@ -160,7 +160,7 @@ Takes a byte-string representation of a regular expression (using the
syntax in @secref["regexp-syntax"]) and compiles it into a syntax in @secref["regexp-syntax"]) and compiles it into a
byte-@tech{regexp value}. byte-@tech{regexp value}.
The @scheme[object-name] procedure The @racket[object-name] procedure
returns the source byte string for a @tech{regexp value}. returns the source byte string for a @tech{regexp value}.
@examples[ @examples[
@ -171,10 +171,10 @@ returns the source byte string for a @tech{regexp value}.
@defproc[(byte-pregexp [bstr bytes?]) byte-pregexp?]{ @defproc[(byte-pregexp [bstr bytes?]) byte-pregexp?]{
Like @scheme[byte-regexp], except that it uses a slightly different Like @racket[byte-regexp], except that it uses a slightly different
syntax (see @secref["regexp-syntax"]). The result can be used with syntax (see @secref["regexp-syntax"]). The result can be used with
@scheme[regexp-match], etc., just like the result from @racket[regexp-match], etc., just like the result from
@scheme[byte-regexp]. @racket[byte-regexp].
@examples[ @examples[
(byte-pregexp #"ap*le") (byte-pregexp #"ap*le")
@ -183,11 +183,11 @@ syntax (see @secref["regexp-syntax"]). The result can be used with
@defproc*[([(regexp-quote [str string?] [case-sensitive? any/c #t]) string?] @defproc*[([(regexp-quote [str string?] [case-sensitive? any/c #t]) string?]
[(regexp-quote [bstr bytes?] [case-sensitive? any/c #t]) bytes?])]{ [(regexp-quote [bstr bytes?] [case-sensitive? any/c #t]) bytes?])]{
Produces a string or byte string suitable for use with @scheme[regexp] Produces a string or byte string suitable for use with @racket[regexp]
to match the literal sequence of characters in @scheme[str] or to match the literal sequence of characters in @racket[str] or
sequence of bytes in @scheme[bstr]. If @scheme[case-sensitive?] is sequence of bytes in @racket[bstr]. If @racket[case-sensitive?] is
true, the resulting regexp matches letters in @scheme[str] or true, the resulting regexp matches letters in @racket[str] or
@scheme[bytes] case-insensitively, otherwise it matches @racket[bytes] case-insensitively, otherwise it matches
case-sensitively. case-sensitively.
@examples[ @examples[
@ -198,7 +198,7 @@ case-sensitively.
@defproc[(regexp-max-lookbehind [pattern (or/c regexp? byte-regexp?)]) @defproc[(regexp-max-lookbehind [pattern (or/c regexp? byte-regexp?)])
exact-nonnegative-integer?]{ exact-nonnegative-integer?]{
Returns the maximum number of bytes that @scheme[pattern] may consult Returns the maximum number of bytes that @racket[pattern] may consult
before the starting position of a match to determine the match. For before the starting position of a match to determine the match. For
example, the pattern @litchar{(?<=abc)d} consults three bytes example, the pattern @litchar{(?<=abc)d} consults three bytes
preceding a matching @litchar{d}, while @litchar{e(?<=a..)d} consults preceding a matching @litchar{d}, while @litchar{e(?<=a..)d} consults
@ -220,93 +220,93 @@ the start of the input or of a line.}
(or/c #f (cons/c string? (listof (or/c string? #f)))) (or/c #f (cons/c string? (listof (or/c string? #f))))
(or/c #f (cons/c bytes? (listof (or/c bytes? #f)))))]{ (or/c #f (cons/c bytes? (listof (or/c bytes? #f)))))]{
Attempts to match @scheme[pattern] (a string, byte string, @tech{regexp Attempts to match @racket[pattern] (a string, byte string, @tech{regexp
value}, or byte-@tech{regexp value}) once to a portion of @scheme[input]. The value}, or byte-@tech{regexp value}) once to a portion of @racket[input]. The
matcher finds a portion of @scheme[input] that matches and is closest matcher finds a portion of @racket[input] that matches and is closest
to the start of the input (after @scheme[start-pos]). to the start of the input (after @racket[start-pos]).
The optional @scheme[start-pos] and @scheme[end-pos] arguments select The optional @racket[start-pos] and @racket[end-pos] arguments select
a portion of @scheme[input] for matching; the default is the entire a portion of @racket[input] for matching; the default is the entire
string or the stream up to an end-of-file. When @scheme[input] is a string or the stream up to an end-of-file. When @racket[input] is a
string, @scheme[start-pos] is a character position; when string, @racket[start-pos] is a character position; when
@scheme[input] is a byte string, then @scheme[start-pos] is a byte @racket[input] is a byte string, then @racket[start-pos] is a byte
position; and when @scheme[input] is an input port, @scheme[start-pos] position; and when @racket[input] is an input port, @racket[start-pos]
is the number of bytes to skip before starting to match. The is the number of bytes to skip before starting to match. The
@scheme[end-pos] argument can be @scheme[#f], which corresponds to the @racket[end-pos] argument can be @racket[#f], which corresponds to the
end of the string or the end-of-file in the stream; otherwise, it is a end of the string or the end-of-file in the stream; otherwise, it is a
character or byte position, like @scheme[start-pos]. If @scheme[input] character or byte position, like @racket[start-pos]. If @racket[input]
is an input port, and if the end-of-file is reached before is an input port, and if the end-of-file is reached before
@scheme[start-pos] bytes are skipped, then the match fails. @racket[start-pos] bytes are skipped, then the match fails.
In @scheme[pattern], a start-of-string @litchar{^} refers to the first In @racket[pattern], a start-of-string @litchar{^} refers to the first
position of @scheme[input] after @scheme[start-pos], assuming that position of @racket[input] after @racket[start-pos], assuming that
@scheme[input-prefix] is @scheme[#""]. The end-of-input @litchar{$} @racket[input-prefix] is @racket[#""]. The end-of-input @litchar{$}
refers to the @scheme[end-pos]th position or (in the case of an input refers to the @racket[end-pos]th position or (in the case of an input
port) the end of file, whichever comes first, assuming that port) the end of file, whichever comes first, assuming that
@scheme[output-prefix] is @scheme[#f]. @racket[output-prefix] is @racket[#f].
The @scheme[input-prefix] specifies bytes that effectively precede The @racket[input-prefix] specifies bytes that effectively precede
@scheme[input] for the purposes of @litchar{^} and other look-behind @racket[input] for the purposes of @litchar{^} and other look-behind
matching. For example, a @scheme[#""] prefix means that @litchar{^} matching. For example, a @racket[#""] prefix means that @litchar{^}
matches at the beginning of the stream, while a @scheme[#"\n"] matches at the beginning of the stream, while a @racket[#"\n"]
@scheme[input-prefix] means that a start-of-line @litchar{^} can match @racket[input-prefix] means that a start-of-line @litchar{^} can match
the beginning of the input, while a start-of-file @litchar{^} cannot. the beginning of the input, while a start-of-file @litchar{^} cannot.
If the match fails, @scheme[#f] is returned. If the match succeeds, a If the match fails, @racket[#f] is returned. If the match succeeds, a
list containing strings or byte string, and possibly @scheme[#f], is list containing strings or byte string, and possibly @racket[#f], is
returned. The list contains strings only if @scheme[input] is a string returned. The list contains strings only if @racket[input] is a string
and @scheme[pattern] is not a byte regexp. Otherwise, the list and @racket[pattern] is not a byte regexp. Otherwise, the list
contains byte strings (substrings of the UTF-8 encoding of contains byte strings (substrings of the UTF-8 encoding of
@scheme[input], if @scheme[input] is a string). @racket[input], if @racket[input] is a string).
The first [byte] string in a result list is the portion of The first [byte] string in a result list is the portion of
@scheme[input] that matched @scheme[pattern]. If two portions of @racket[input] that matched @racket[pattern]. If two portions of
@scheme[input] can match @scheme[pattern], then the match that starts @racket[input] can match @racket[pattern], then the match that starts
earliest is found. earliest is found.
Additional [byte] strings are returned in the list if @scheme[pattern] Additional [byte] strings are returned in the list if @racket[pattern]
contains parenthesized sub-expressions (but not when the open contains parenthesized sub-expressions (but not when the open
parenthesis is followed by @litchar{?:}). Matches for the parenthesis is followed by @litchar{?:}). Matches for the
sub-expressions are provided in the order of the opening parentheses sub-expressions are provided in the order of the opening parentheses
in @scheme[pattern]. When sub-expressions occur in branches of an in @racket[pattern]. When sub-expressions occur in branches of an
@litchar{|} ``or'' pattern, in a @litchar{*} ``zero or more'' @litchar{|} ``or'' pattern, in a @litchar{*} ``zero or more''
pattern, or other places where the overall pattern can succeed without pattern, or other places where the overall pattern can succeed without
a match for the sub-expression, then a @scheme[#f] is returned for the a match for the sub-expression, then a @racket[#f] is returned for the
sub-expression if it did not contribute to the final match. When a sub-expression if it did not contribute to the final match. When a
single sub-expression occurs within a @litchar{*} ``zero or more'' single sub-expression occurs within a @litchar{*} ``zero or more''
pattern or other multiple-match positions, then the rightmost match pattern or other multiple-match positions, then the rightmost match
associated with the sub-expression is returned in the list. associated with the sub-expression is returned in the list.
If the optional @scheme[output-port] is provided as an output port, If the optional @racket[output-port] is provided as an output port,
the part of @scheme[input] from its beginning (not @scheme[start-pos]) the part of @racket[input] from its beginning (not @racket[start-pos])
that precedes the match is written to the port. All of @scheme[input] that precedes the match is written to the port. All of @racket[input]
up to @scheme[end-pos] is written to the port if no match is up to @racket[end-pos] is written to the port if no match is
found. This functionality is most useful when @scheme[input] is an found. This functionality is most useful when @racket[input] is an
input port. input port.
When matching an input port, a match failure reads up to When matching an input port, a match failure reads up to
@scheme[end-pos] bytes (or end-of-file), even if @scheme[pattern] @racket[end-pos] bytes (or end-of-file), even if @racket[pattern]
begins with a start-of-string @litchar{^}; see also begins with a start-of-string @litchar{^}; see also
@scheme[regexp-try-match]. On success, all bytes up to and including @racket[regexp-try-match]. On success, all bytes up to and including
the match are eventually read from the port, but matching proceeds by the match are eventually read from the port, but matching proceeds by
first peeking bytes from the port (using @scheme[peek-bytes-avail!]), first peeking bytes from the port (using @racket[peek-bytes-avail!]),
and then (re-)reading matching bytes to discard them after the match and then (re-)reading matching bytes to discard them after the match
result is determined. Non-matching bytes may be read and discarded result is determined. Non-matching bytes may be read and discarded
before the match is determined. The matcher peeks in blocking mode before the match is determined. The matcher peeks in blocking mode
only as far as necessary to determine a match, but it may peek extra only as far as necessary to determine a match, but it may peek extra
bytes to fill an internal buffer if immediately available (i.e., bytes to fill an internal buffer if immediately available (i.e.,
without blocking). Greedy repeat operators in @scheme[pattern], such without blocking). Greedy repeat operators in @racket[pattern], such
as @litchar{*} or @litchar{+}, tend to force reading the entire as @litchar{*} or @litchar{+}, tend to force reading the entire
content of the port (up to @scheme[end-pos]) to determine a match. content of the port (up to @racket[end-pos]) to determine a match.
If the input port is read simultaneously by another thread, or if the If the input port is read simultaneously by another thread, or if the
port is a custom port with inconsistent reading and peeking procedures port is a custom port with inconsistent reading and peeking procedures
(see @secref["customport"]), then the bytes that are peeked and (see @secref["customport"]), then the bytes that are peeked and
used for matching may be different than the bytes read and discarded used for matching may be different than the bytes read and discarded
after the match completes; the matcher inspects only the peeked after the match completes; the matcher inspects only the peeked
bytes. To avoid such interleaving, use @scheme[regexp-match-peek] bytes. To avoid such interleaving, use @racket[regexp-match-peek]
(with a @scheme[progress-evt] argument) followed by (with a @racket[progress-evt] argument) followed by
@scheme[port-commit-peeked]. @racket[port-commit-peeked].
@examples[ @examples[
(regexp-match #rx"x." "12x4x6") (regexp-match #rx"x." "12x4x6")
@ -329,27 +329,27 @@ bytes. To avoid such interleaving, use @scheme[regexp-match-peek]
(listof string?) (listof string?)
(listof bytes?))]{ (listof bytes?))]{
Like @scheme[regexp-match], but the result is a list of strings or Like @racket[regexp-match], but the result is a list of strings or
byte strings corresponding to a sequence of matches of byte strings corresponding to a sequence of matches of
@scheme[pattern] in @scheme[input]. (Unlike @scheme[regexp-match], @racket[pattern] in @racket[input]. (Unlike @racket[regexp-match],
results for parenthesized sub-patterns in @scheme[pattern] are not results for parenthesized sub-patterns in @racket[pattern] are not
returned.) returned.)
The @scheme[pattern] is used in order to find matches, where each The @racket[pattern] is used in order to find matches, where each
match attempt starts at the end of the last match, and @litchar{^} is match attempt starts at the end of the last match, and @litchar{^} is
allowed to match the beginning of the input (if @scheme[input-prefix] allowed to match the beginning of the input (if @racket[input-prefix]
is @scheme[#""]) only for the first match. Empty matches are handled is @racket[#""]) only for the first match. Empty matches are handled
like other matches, returning a zero-length string or byte sequence like other matches, returning a zero-length string or byte sequence
(they are more useful in the complementing @scheme[regexp-split] (they are more useful in the complementing @racket[regexp-split]
function), but @scheme[pattern] is restricted from matching an empty function), but @racket[pattern] is restricted from matching an empty
sequence immediately after an empty match. sequence immediately after an empty match.
If @scheme[input] contains no matches (in the range @scheme[start-pos] If @racket[input] contains no matches (in the range @racket[start-pos]
to @scheme[end-pos]), @scheme[null] is returned. Otherwise, each item to @racket[end-pos]), @racket[null] is returned. Otherwise, each item
in the resulting list is a distinct substring or byte sequence from in the resulting list is a distinct substring or byte sequence from
@scheme[input] that matches @scheme[pattern]. The @scheme[end-pos] @racket[input] that matches @racket[pattern]. The @racket[end-pos]
argument can be @scheme[#f] to match to the end of @scheme[input] argument can be @racket[#f] to match to the end of @racket[input]
(which corresponds to an end-of-file if @scheme[input] is an input (which corresponds to an end-of-file if @racket[input] is an input
port). port).
@examples[ @examples[
@ -369,12 +369,12 @@ port).
(or/c #f (cons/c string? (listof (or/c string? #f)))) (or/c #f (cons/c string? (listof (or/c string? #f))))
(or/c #f (cons/c bytes? (listof (or/c bytes? #f)))))]{ (or/c #f (cons/c bytes? (listof (or/c bytes? #f)))))]{
Like @scheme[regexp-match] on input ports, except that if the match Like @racket[regexp-match] on input ports, except that if the match
fails, no characters are read and discarded from @scheme[in]. fails, no characters are read and discarded from @racket[in].
This procedure is especially useful with a @scheme[pattern] that This procedure is especially useful with a @racket[pattern] that
begins with a start-of-string @litchar{^} or with a non-@scheme[#f] begins with a start-of-string @litchar{^} or with a non-@racket[#f]
@scheme[end-pos], since each limits the amount of peeking into the @racket[end-pos], since each limits the amount of peeking into the
port. Otherwise, beware that a large portion of the stream may be port. Otherwise, beware that a large portion of the stream may be
peeked (and therefore pulled into memory) before the match succeeds or peeked (and therefore pulled into memory) before the match succeeds or
fails.} fails.}
@ -393,19 +393,19 @@ fails.}
#f))) #f)))
#f)]{ #f)]{
Like @scheme[regexp-match], but returns a list of number pairs (and Like @racket[regexp-match], but returns a list of number pairs (and
@scheme[#f]) instead of a list of strings. Each pair of numbers refers @racket[#f]) instead of a list of strings. Each pair of numbers refers
to a range of characters or bytes in @scheme[input]. If the result for to a range of characters or bytes in @racket[input]. If the result for
the same arguments with @scheme[regexp-match] would be a list of byte the same arguments with @racket[regexp-match] would be a list of byte
strings, the resulting ranges correspond to byte ranges; in that case, strings, the resulting ranges correspond to byte ranges; in that case,
if @scheme[input] is a character string, the byte ranges correspond to if @racket[input] is a character string, the byte ranges correspond to
bytes in the UTF-8 encoding of the string. bytes in the UTF-8 encoding of the string.
Range results are returned in a @scheme[substring]- and Range results are returned in a @racket[substring]- and
@scheme[subbytes]-compatible manner, independent of @racket[subbytes]-compatible manner, independent of
@scheme[start-pos]. In the case of an input port, the returned @racket[start-pos]. In the case of an input port, the returned
positions indicate the number of bytes that were read, including positions indicate the number of bytes that were read, including
@scheme[start-pos], before the first matching byte. @racket[start-pos], before the first matching byte.
@examples[ @examples[
(regexp-match-positions #rx"x." "12x4x6") (regexp-match-positions #rx"x." "12x4x6")
@ -421,8 +421,8 @@ positions indicate the number of bytes that were read, including
(listof (cons/c exact-nonnegative-integer? (listof (cons/c exact-nonnegative-integer?
exact-nonnegative-integer?))]{ exact-nonnegative-integer?))]{
Like @scheme[regexp-match-positions], but returns multiple matches Like @racket[regexp-match-positions], but returns multiple matches
like @scheme[regexp-match*]. like @racket[regexp-match*].
@examples[ @examples[
(regexp-match-positions #rx"x." "12x4x6") (regexp-match-positions #rx"x." "12x4x6")
@ -437,8 +437,8 @@ like @scheme[regexp-match*].
[input-prefix bytes? #""]) [input-prefix bytes? #""])
boolean?]{ boolean?]{
Like @scheme[regexp-match], but returns merely @scheme[#t] when the Like @racket[regexp-match], but returns merely @racket[#t] when the
match succeeds, @scheme[#f] otherwise. match succeeds, @racket[#f] otherwise.
@examples[ @examples[
(regexp-match? #rx"x." "12x4x6") (regexp-match? #rx"x." "12x4x6")
@ -450,8 +450,8 @@ match succeeds, @scheme[#f] otherwise.
[input (or/c string? bytes? input-port?)]) [input (or/c string? bytes? input-port?)])
boolean?]{ boolean?]{
Like @scheme[regexp-match?], but @scheme[#t] is only returned when the Like @racket[regexp-match?], but @racket[#t] is only returned when the
entire content of @scheme[input] matches @scheme[pattern]. entire content of @racket[input] matches @racket[pattern].
@examples[ @examples[
(regexp-match-exact? #rx"x." "12x4x6") (regexp-match-exact? #rx"x." "12x4x6")
@ -468,15 +468,15 @@ entire content of @scheme[input] matches @scheme[pattern].
(or/c (cons/c bytes? (listof (or/c bytes? #f))) (or/c (cons/c bytes? (listof (or/c bytes? #f)))
#f)]{ #f)]{
Like @scheme[regexp-match] on input ports, but only peeks bytes from Like @racket[regexp-match] on input ports, but only peeks bytes from
@scheme[input] instead of reading them. Furthermore, instead of @racket[input] instead of reading them. Furthermore, instead of
an output port, the last optional argument is a progress event for an output port, the last optional argument is a progress event for
@scheme[input] (see @scheme[port-progress-evt]). If @scheme[progress] @racket[input] (see @racket[port-progress-evt]). If @racket[progress]
becomes ready, then the match stops peeking from @scheme[input] becomes ready, then the match stops peeking from @racket[input]
and returns @scheme[#f]. The @scheme[progress] argument can be and returns @racket[#f]. The @racket[progress] argument can be
@scheme[#f], in which case the peek may continue with inconsistent @racket[#f], in which case the peek may continue with inconsistent
information if another process meanwhile reads from information if another process meanwhile reads from
@scheme[input]. @racket[input].
@examples[ @examples[
(define p (open-input-string "a abcd")) (define p (open-input-string "a abcd"))
@ -502,9 +502,9 @@ information if another process meanwhile reads from
#f))) #f)))
#f)]{ #f)]{
Like @scheme[regexp-match-positions] on input ports, but only peeks Like @racket[regexp-match-positions] on input ports, but only peeks
bytes from @scheme[input] instead of reading them, and with a bytes from @racket[input] instead of reading them, and with a
@scheme[progress] argument like @scheme[regexp-match-peek].} @racket[progress] argument like @racket[regexp-match-peek].}
@defproc[(regexp-match-peek-immediate [pattern (or/c string? bytes? regexp? byte-regexp?)] @defproc[(regexp-match-peek-immediate [pattern (or/c string? bytes? regexp? byte-regexp?)]
@ -516,10 +516,10 @@ bytes from @scheme[input] instead of reading them, and with a
(or/c (cons/c bytes? (listof (or/c bytes? #f))) (or/c (cons/c bytes? (listof (or/c bytes? #f)))
#f)]{ #f)]{
Like @scheme[regexp-match-peek], but it attempts to match only bytes Like @racket[regexp-match-peek], but it attempts to match only bytes
that are available from @scheme[input] without blocking. The that are available from @racket[input] without blocking. The
match fails if not-yet-available characters might be used to match match fails if not-yet-available characters might be used to match
@scheme[pattern].} @racket[pattern].}
@defproc[(regexp-match-peek-positions-immediate [pattern (or/c string? bytes? regexp? byte-regexp?)] @defproc[(regexp-match-peek-positions-immediate [pattern (or/c string? bytes? regexp? byte-regexp?)]
@ -535,10 +535,10 @@ match fails if not-yet-available characters might be used to match
#f))) #f)))
#f)]{ #f)]{
Like @scheme[regexp-match-peek-positions], but it attempts to match Like @racket[regexp-match-peek-positions], but it attempts to match
only bytes that are available from @scheme[input] without only bytes that are available from @racket[input] without
blocking. The match fails if not-yet-available characters might be blocking. The match fails if not-yet-available characters might be
used to match @scheme[pattern].} used to match @racket[pattern].}
@defproc[(regexp-match-peek-positions* [pattern (or/c string? bytes? regexp? byte-regexp?)] @defproc[(regexp-match-peek-positions* [pattern (or/c string? bytes? regexp? byte-regexp?)]
@ -549,8 +549,8 @@ used to match @scheme[pattern].}
(listof (cons/c exact-nonnegative-integer? (listof (cons/c exact-nonnegative-integer?
exact-nonnegative-integer?))]{ exact-nonnegative-integer?))]{
Like @scheme[regexp-match-peek-positions], but returns multiple matches like Like @racket[regexp-match-peek-positions], but returns multiple matches like
@scheme[regexp-match*].} @racket[regexp-match*].}
@defproc[(regexp-match/end [pattern (or/c string? bytes? regexp? byte-regexp?)] @defproc[(regexp-match/end [pattern (or/c string? bytes? regexp? byte-regexp?)]
[input (or/c string? bytes? input-port?)] [input (or/c string? bytes? input-port?)]
@ -566,15 +566,15 @@ Like @scheme[regexp-match-peek-positions], but returns multiple matches like
(or/c #f (cons/c bytes? (listof (or/c bytes? #f))))) (or/c #f (cons/c bytes? (listof (or/c bytes? #f)))))
(or/c #f bytes?))]{ (or/c #f bytes?))]{
Like @scheme[regexp-match], but with a second result: a byte Like @racket[regexp-match], but with a second result: a byte
string of up to @scheme[count] bytes that correspond to the input string of up to @racket[count] bytes that correspond to the input
(possibly including the @scheme[input-prefix]) leading to the end of (possibly including the @racket[input-prefix]) leading to the end of
the match; the second result is @scheme[#f] if no match is found. the match; the second result is @racket[#f] if no match is found.
The second result can be useful as an @scheme[input-prefix] for The second result can be useful as an @racket[input-prefix] for
attempting a second match on @scheme[input] starting from the end of attempting a second match on @racket[input] starting from the end of
the first match. In that case, use @scheme[regexp-max-lookbehind] the first match. In that case, use @racket[regexp-max-lookbehind]
to determine an appropriate value for @scheme[count].} to determine an appropriate value for @racket[count].}
@deftogether[( @deftogether[(
@defproc[(regexp-match-positions/end [pattern (or/c string? bytes? regexp? byte-regexp?)] @defproc[(regexp-match-positions/end [pattern (or/c string? bytes? regexp? byte-regexp?)]
@ -618,8 +618,8 @@ to determine an appropriate value for @scheme[count].}
(or/c #f bytes?))] (or/c #f bytes?))]
)]{ )]{
Like @scheme[regexp-match-positions], etc., but with a second result Like @racket[regexp-match-positions], etc., but with a second result
like @scheme[regexp-match/end].} like @racket[regexp-match/end].}
@;------------------------------------------------------------------------ @;------------------------------------------------------------------------
@section{Regexp Splitting} @section{Regexp Splitting}
@ -634,24 +634,24 @@ like @scheme[regexp-match/end].}
(cons/c string? (listof string?)) (cons/c string? (listof string?))
(cons/c bytes? (listof bytes?)))]{ (cons/c bytes? (listof bytes?)))]{
The complement of @scheme[regexp-match*]: the result is a list of The complement of @racket[regexp-match*]: the result is a list of
strings (if @scheme[pattern] is a string or character regexp and strings (if @racket[pattern] is a string or character regexp and
@scheme[input] is a string) or byte strings (otherwise) from in @racket[input] is a string) or byte strings (otherwise) from in
@scheme[input] that are separated by matches to @racket[input] that are separated by matches to
@scheme[pattern]. Adjacent matches are separated with @scheme[""] or @racket[pattern]. Adjacent matches are separated with @racket[""] or
@scheme[#""]. Zero-length matches are treated the same as for @racket[#""]. Zero-length matches are treated the same as for
@scheme[regexp-match*]. @racket[regexp-match*].
If @scheme[input] contains no matches (in the range @scheme[start-pos] If @racket[input] contains no matches (in the range @racket[start-pos]
to @scheme[end-pos]), the result is a list containing @scheme[input]'s to @racket[end-pos]), the result is a list containing @racket[input]'s
content (from @scheme[start-pos] to @scheme[end-pos]) as a single content (from @racket[start-pos] to @racket[end-pos]) as a single
element. If a match occurs at the beginning of @scheme[input] (at element. If a match occurs at the beginning of @racket[input] (at
@scheme[start-pos]), the resulting list will start with an empty @racket[start-pos]), the resulting list will start with an empty
string or byte string, and if a match occurs at the end (at string or byte string, and if a match occurs at the end (at
@scheme[end-pos]), the list will end with an empty string or byte @racket[end-pos]), the list will end with an empty string or byte
string. The @scheme[end-pos] argument can be @scheme[#f], in which string. The @racket[end-pos] argument can be @racket[#f], in which
case splitting goes to the end of @scheme[input] (which corresponds to case splitting goes to the end of @racket[input] (which corresponds to
an end-of-file if @scheme[input] is an input port). an end-of-file if @racket[input] is an input port).
@examples[ @examples[
(regexp-split #rx" +" "12 34") (regexp-split #rx" +" "12 34")
@ -675,52 +675,52 @@ an end-of-file if @scheme[input] is an input port).
string? string?
bytes?)]{ bytes?)]{
Performs a match using @scheme[pattern] on @scheme[input], and then Performs a match using @racket[pattern] on @racket[input], and then
returns a string or byte string in which the matching portion of returns a string or byte string in which the matching portion of
@scheme[input] is replaced with @scheme[insert]. If @scheme[pattern] @racket[input] is replaced with @racket[insert]. If @racket[pattern]
matches no part of @scheme[input], then @scheme[iput] is returned matches no part of @racket[input], then @racket[iput] is returned
unmodified. unmodified.
The @scheme[insert] argument can be either a (byte) string, or a The @racket[insert] argument can be either a (byte) string, or a
function that returns a (byte) string. In the latter case, the function that returns a (byte) string. In the latter case, the
function is applied on the list of values that @scheme[regexp-match] function is applied on the list of values that @racket[regexp-match]
would return (i.e., the first argument is the complete match, and then would return (i.e., the first argument is the complete match, and then
one argument for each parenthesized sub-expression) to obtain a one argument for each parenthesized sub-expression) to obtain a
replacement (byte) string. replacement (byte) string.
If @scheme[pattern] is a string or character regexp and @scheme[input] If @racket[pattern] is a string or character regexp and @racket[input]
is a string, then @scheme[insert] must be a string or a procedure that is a string, then @racket[insert] must be a string or a procedure that
accept strings, and the result is a string. If @scheme[pattern] is a accept strings, and the result is a string. If @racket[pattern] is a
byte string or byte regexp, or if @scheme[input] is a byte string, byte string or byte regexp, or if @racket[input] is a byte string,
then @scheme[insert] as a string is converted to a byte string, then @racket[insert] as a string is converted to a byte string,
@scheme[insert] as a procedure is called with a byte string, and the @racket[insert] as a procedure is called with a byte string, and the
result is a byte string. result is a byte string.
If @scheme[insert] contains @litchar{&}, then @litchar{&} If @racket[insert] contains @litchar{&}, then @litchar{&}
is replaced with the matching portion of @scheme[input] before it is is replaced with the matching portion of @racket[input] before it is
substituted into the match's place. If @scheme[insert] contains substituted into the match's place. If @racket[insert] contains
@litchar{\}@nonterm{n} for some integer @nonterm{n}, then it is @litchar{\}@nonterm{n} for some integer @nonterm{n}, then it is
replaced with the @nonterm{n}th matching sub-expression from replaced with the @nonterm{n}th matching sub-expression from
@scheme[input]. A @litchar{&} and @litchar{\0} are synonymous. If @racket[input]. A @litchar{&} and @litchar{\0} are synonymous. If
the @nonterm{n}th sub-expression was not used in the match, or if the @nonterm{n}th sub-expression was not used in the match, or if
@nonterm{n} is greater than the number of sub-expressions in @nonterm{n} is greater than the number of sub-expressions in
@scheme[pattern], then @litchar{\}@nonterm{n} is replaced with the @racket[pattern], then @litchar{\}@nonterm{n} is replaced with the
empty string. empty string.
To substitute a literal @litchar{&} or @litchar{\}, use To substitute a literal @litchar{&} or @litchar{\}, use
@litchar{\&} and @litchar{\\}, respectively, in @litchar{\&} and @litchar{\\}, respectively, in
@scheme[insert]. A @litchar{\$} in @scheme[insert] is @racket[insert]. A @litchar{\$} in @racket[insert] is
equivalent to an empty sequence; this can be used to terminate a equivalent to an empty sequence; this can be used to terminate a
number @nonterm{n} following @litchar{\}. If a @litchar{\} in number @nonterm{n} following @litchar{\}. If a @litchar{\} in
@scheme[insert] is followed by anything other than a digit, @racket[insert] is followed by anything other than a digit,
@litchar{&}, @litchar{\}, or @litchar{$}, then the @litchar{\} @litchar{&}, @litchar{\}, or @litchar{$}, then the @litchar{\}
by itself is treated as @litchar{\0}. by itself is treated as @litchar{\0}.
Note that the @litchar{\} described in the previous paragraphs is a Note that the @litchar{\} described in the previous paragraphs is a
character or byte of @scheme[input]. To write such an @scheme[input] character or byte of @racket[input]. To write such an @racket[input]
as a Scheme string literal, an escaping @litchar{\} is needed as a Racket string literal, an escaping @litchar{\} is needed
before the @litchar{\}. For example, the Scheme constant before the @litchar{\}. For example, the Racket constant
@scheme["\\1"] is @litchar{\1}. @racket["\\1"] is @litchar{\1}.
@examples[ @examples[
(regexp-replace "mi" "mi casa" "su") (regexp-replace "mi" "mi casa" "su")
@ -740,13 +740,13 @@ before the @litchar{\}. For example, the Scheme constant
[input-prefix bytes? #""]) [input-prefix bytes? #""])
(or/c string? bytes?)]{ (or/c string? bytes?)]{
Like @scheme[regexp-replace], except that every instance of Like @racket[regexp-replace], except that every instance of
@scheme[pattern] in @scheme[input] is replaced with @scheme[insert], @racket[pattern] in @racket[input] is replaced with @racket[insert],
instead of just the first match. Only non-overlapping instances of instead of just the first match. Only non-overlapping instances of
@scheme[pattern] in @scheme[input] are replaced, so instances of @racket[pattern] in @racket[input] are replaced, so instances of
@scheme[pattern] within inserted strings are @italic{not} replaced @racket[pattern] within inserted strings are @italic{not} replaced
recursively. Zero-length matches are treated the same as in recursively. Zero-length matches are treated the same as in
@scheme[regexp-match*]. @racket[regexp-match*].
@examples[ @examples[
(regexp-replace* "([Mm])i ([a-zA-Z]*)" "mi cerveza Mi Mi Mi" (regexp-replace* "([Mm])i ([a-zA-Z]*)" "mi cerveza Mi Mi Mi"
@ -762,10 +762,10 @@ recursively. Zero-length matches are treated the same as in
[(regexp-replace-quote [bstr bytes?]) bytes?])]{ [(regexp-replace-quote [bstr bytes?]) bytes?])]{
Produces a string suitable for use as the third argument to Produces a string suitable for use as the third argument to
@scheme[regexp-replace] to insert the literal sequence of characters @racket[regexp-replace] to insert the literal sequence of characters
in @scheme[str] or bytes in @scheme[bstr] as a replacement. in @racket[str] or bytes in @racket[bstr] as a replacement.
Concretely, every @litchar{\} and @litchar{&} in @scheme[str] or Concretely, every @litchar{\} and @litchar{&} in @racket[str] or
@scheme[bstr] is protected by a quoting @litchar{\}. @racket[bstr] is protected by a quoting @litchar{\}.
@examples[ @examples[
(regexp-replace "UT" "Go UT!" "A&M") (regexp-replace "UT" "Go UT!" "A&M")

View File

@ -331,8 +331,9 @@ the generator runs out of values to yield, the last value it computed
will be returned for future invocations of the generator. Generators will be returned for future invocations of the generator. Generators
can be safely nested. can be safely nested.
Note: the first form must be @scheme[()], and in the future this will Note: The first form must be @scheme[()]. In the future, the
hold argument names that are used in the initial generator call. @scheme[()] position will hold argument names that are used for the
initial generator call.
@examples[#:eval (generator-eval) @examples[#:eval (generator-eval)
(define g (generator () (define g (generator ()

View File

@ -52,11 +52,13 @@ to a later element takes precedence over the later element.}
Returns @scheme[#t] if @scheme[set] has no members, @scheme[#f] Returns @scheme[#t] if @scheme[set] has no members, @scheme[#f]
otherwise.} otherwise.}
@defproc[(set-member? [set set?] [v any/c]) boolean?]{ @defproc[(set-member? [set set?] [v any/c]) boolean?]{
Returns @scheme[#t] if @scheme[v] is in @scheme[set], @scheme[#f] Returns @scheme[#t] if @scheme[v] is in @scheme[set], @scheme[#f]
otherwise.} otherwise.}
@defproc[(set-add [set set?] [v any/c]) set?]{ @defproc[(set-add [set set?] [v any/c]) set?]{
@margin-note{Like operations on immutable hash tables, ``constant @margin-note{Like operations on immutable hash tables, ``constant
@ -101,6 +103,15 @@ runs in time proportional to the total size of all given
@scheme[set]s except the first one.} @scheme[set]s except the first one.}
@defproc[(set-subset? [set set?] [set2 set?]) boolean?]{
Returns @scheme[#t] if every member of @scheme[set2] is in
@scheme[set], @scheme[#f] otherwise. The @scheme[set] and
@scheme[set2] must use the same equivalence predicate
(@scheme[equal?], @scheme[eq?], or @scheme[eqv?]). This operation
runs in time proportional to the size of @scheme[set2].}
@defproc[(set-map [set set?] @defproc[(set-map [set set?]
[proc (any/c . -> . any/c)]) [proc (any/c . -> . any/c)])
(listof any/c)]{ (listof any/c)]{

View File

@ -50,6 +50,11 @@
(test #t set-member? (set-remove s 5) 3) (test #t set-member? (set-remove s 5) 3)
(test #f set-member? (set-remove s 3) 3) (test #f set-member? (set-remove s 3) 3)
(test #t set-subset? s (set 1 3))
(test #t set-subset? s (set 1 2 3))
(test #f set-subset? s (set 1 4))
(test #t set-subset? s (set))
(test 3 set-count (set-union s)) (test 3 set-count (set-union s))
(test 6 set-count (set-union s (set 3 4 5 6))) (test 6 set-count (set-union s (set 3 4 5 6)))
(test 6 set-count (set-union (set 3 4 5 6) s)) (test 6 set-count (set-union (set 3 4 5 6) s))