- Page 1 and 2:
Reference: PLT Scheme Version 4.2 M
- Page 3 and 4:
1.2.6 Inferred Value Names . . . .
- Page 5 and 6:
3.3.3 String Conversions . . . . .
- Page 7 and 8:
4.4 Copying and Updating Structures
- Page 9 and 10:
9.2.1 Raising Exceptions . . . . .
- Page 11 and 12:
12.1.9 Custom Ports . . . . . . . .
- Page 13 and 14:
12.11Serialization . . . . . . . .
- Page 15 and 16:
16 Running PLT Scheme 688 16.1 Runn
- Page 17 and 18:
continuation. For example, the (+ 1
- Page 19 and 20:
1.1.5 Objects and Imperative Update
- Page 21 and 22:
esentation created with datum->synt
- Page 23 and 24:
accessed directly. Generating a loc
- Page 25 and 26:
form is like define, but it defines
- Page 27 and 28:
In addition to the state that is sh
- Page 29 and 30:
dants, unless the custodian can rea
- Page 31 and 32:
For example, the when the program w
- Page 33 and 34:
is 1 (for which comparisons are mad
- Page 35 and 36:
level 0 for each normal provide, ph
- Page 37 and 38:
The set! form works with the make-s
- Page 39 and 40:
During compilation, the top-level o
- Page 41 and 42:
(let ([n (make-base-namespace)]) ;
- Page 43 and 44:
2 Syntactic Forms This section desc
- Page 45 and 46:
The scope of all imported identifie
- Page 47 and 48:
equire-spec = module-path | (only-i
- Page 49 and 50:
Examples: > (require (except-in sch
- Page 51 and 52:
Examples: > (module nest scheme (pr
- Page 53 and 54:
the "mzlib" collection. (This conve
- Page 55 and 56:
provide-spec = id | (all-defined-ou
- Page 57 and 58:
Examples: > (module nest scheme (pr
- Page 59 and 60:
Examples: > (module nest scheme (pr
- Page 61 and 62:
aw-require-spec = phaseless-spec |
- Page 63 and 64:
2.2.1 Additional require Forms (req
- Page 65 and 66:
(matching-identifiers-out regexp pr
- Page 67 and 68:
Examples: > (define x 10) > x 10 >
- Page 69 and 70:
Examples: > (#%app + 1 2) 3 > (#%ap
- Page 71 and 72:
The position of a keyword arg in kw
- Page 73 and 74:
The last body expression is in tail
- Page 75 and 76:
(letrec-values ([(is-even is-odd) (
- Page 77 and 78:
in-immutable-expr = shell-id | shel
- Page 79 and 80:
(if (positive -5) (error "doesn’t
- Page 81 and 82:
1 > (and (values 1 2)) 1 2 > (and #
- Page 83 and 84:
head = id | (head args) args = arg
- Page 85 and 86:
(define-syntaxes (foo1 foo2 foo3) (
- Page 87 and 88:
The first form is like define-synta
- Page 89 and 90:
Equivalent to (when (not test-expr)
- Page 91 and 92:
The for form iterates by drawing an
- Page 93 and 94:
Iterates like for, but when last ex
- Page 95 and 96:
(for*/fold ([accum-id init-expr] ..
- Page 97 and 98:
step-expr-maybe = | step-expr Itera
- Page 99 and 100:
‘(1 ‘‘‘,,@,,@(list (+ 1 2))
- Page 101 and 102:
eference to undefined identifier: r
- Page 103 and 104:
[with-handlers ([exn:fail (lambda (
- Page 105 and 106:
Two values are equal if and only if
- Page 107 and 108:
• equal-proc : (-> any/c any/c (-
- Page 109 and 110:
Inexact real numbers are implemente
- Page 111 and 112:
#t > (integer +inf.0) #f > (integer
- Page 113 and 114:
(even n) → boolean n : integer Re
- Page 115 and 116:
(- z) → number z : number (- z w
- Page 117 and 118:
(quotient/remainder n m) → number
- Page 119 and 120:
10 > (gcd 12 81.0) 3.0 (lcm n ...)
- Page 121 and 122:
(denominator q) → integer q : rat
- Page 123 and 124:
(> 3 2 1) #t > (> +inf.0 1) #t > (<
- Page 125 and 126:
(log z) → number z : number Retur
- Page 127 and 128:
(atan 2 1) 1.1071487177940904 > (at
- Page 129 and 130:
(bitwise-ior n ...) → exact-integ
- Page 131 and 132:
is non-negative, the integer n is s
- Page 133 and 134:
Like vector->pseudo-random-generato
- Page 135 and 136:
Converts the exact integer n to a m
- Page 137 and 138:
0 (conjugate z) → number z : numb
- Page 139 and 140:
Returns the length of str. Examples
- Page 141 and 142:
s "qqqqq" (string-append str ...)
- Page 143 and 144:
#f > (string str1 str2 ...+) → bo
- Page 145 and 146:
(string-ci>= str1 str2 ...+) → bo
- Page 147 and 148:
(string-normalize-nfc string) → s
- Page 149 and 150:
"abcd" > (string-append* (cdr (appe
- Page 151 and 152:
(bytes-length bstr) → exact-nonne
- Page 153 and 154:
Examples: > (define s (bytes 65 112
- Page 155 and 156:
str : bytes err-char : (or/c #f cha
- Page 157 and 158:
str : bytes err-char : (or/c #f cha
- Page 159 and 160:
A newly opened byte converter is re
- Page 161 and 162:
dest-end-pos : (or/c exact-nonnegat
- Page 163 and 164:
#t > (char= #\a #\A #\a) #f (char<
- Page 165 and 166:
(char-ci #\A #\a) #f > (char-ci> #\
- Page 167 and 168:
duces #t when applied to char: char
- Page 169 and 170:
char : char Like char-upcase, but f
- Page 171 and 172:
and Locales”) of matching charact
- Page 173 and 174:
| 〈class〉 Match any character i
- Page 175 and 176:
〈atom〉 : [n, m] n > 0 〈atom
- Page 177 and 178:
(pregexp "ap*le") #px"ap*le" > (reg
- Page 179 and 180: portions of input can match pattern
- Page 181 and 182: output-port : (or/c output-port #f)
- Page 183 and 184: (regexp-match-exact #rx"x." "12x4x6
- Page 185 and 186: Like regexp-match-peek-positions, b
- Page 187 and 188: Note that the \ described in the pr
- Page 189 and 190: Returns #t if the arguments are sor
- Page 191 and 192: (length lst) → exact-nonnegative-
- Page 193 and 194: case proc is not applied to later e
- Page 195 and 196: Returns (remove v lst eqv). (remove
- Page 197 and 198: Like member, but finds an element u
- Page 199 and 200: (cdadr v) → any/c v : (cons/c any
- Page 201 and 202: (cddadr v) → any/c v : (cons/c an
- Page 203 and 204: lst : list Returns the ninth elemen
- Page 205 and 206: (drop-right ’non-list 0) () (spli
- Page 207 and 208: Similar to filter, except that two
- Page 209 and 210: Examples: > (let* ([ph (make-placeh
- Page 211 and 212: (set-mcdr! p v) → void p : mpair
- Page 213 and 214: (mmap proc mlst ...+) → mlist pro
- Page 215 and 216: to contain the given vs in order. (
- Page 217 and 218: (build-vector n proc) → vector n
- Page 219 and 220: a key string is modified with strin
- Page 221 and 222: (hash-set hash key v) → (and/c ha
- Page 223 and 224: (hash-remove hash key) → (and/c h
- Page 225 and 226: Returns an exact integer; for any t
- Page 227 and 228: Returns a sequence equivalent to ls
- Page 229: Returns a sequence whose elements a
- Page 233 and 234: #t > (dict-mutable ’#("apple" "ba
- Page 235 and 236: Examples: > (dict-ref #hash((b. "be
- Page 237 and 238: #hash((a. "apple")) > (dict-remove
- Page 239 and 240: (define i (dict-iterate-first h)) >
- Page 241 and 242: • iterate-first : a procedure lik
- Page 243 and 244: proc : procedure Returns a procedur
- Page 245 and 246: (arity-at-least-value (procedure-ar
- Page 247 and 248: allowed-kws : (or/c (listof keyword
- Page 249 and 250: plying the value with the prop:proc
- Page 251 and 252: (primitive-result-arity prim) → p
- Page 253 and 254: proc : procedure v : any/c Like cur
- Page 255 and 256: 4.1 Defining Structure Types: defin
- Page 257 and 258: (define-struct posn (x y [z #:auto]
- Page 259 and 260: immutables : (listof exact-nonnegat
- Page 261 and 262: (define-values (struct:c make-c c c
- Page 263 and 264: a value for the property supplied t
- Page 265 and 266: field is inaccessible.) (struct v)
- Page 267 and 268: Examples: > (make-prefab-struct ’
- Page 269 and 270: (checked-struct-info v) → boolean
- Page 271 and 272: A class can implement any number of
- Page 273 and 274: class-clause = (inspect inspector-e
- Page 275 and 276: Like class*, but omits the interfac
- Page 277 and 278: syntax error. (inherit maybe-rename
- Page 279 and 280: Shorthand for (begin (public-final
- Page 281 and 282:
If an initialization argument is no
- Page 283 and 284:
A method declared with public, pubm
- Page 285 and 286:
If a method declared with inherit,
- Page 287 and 288:
Produces a hidden name, just like t
- Page 289 and 290:
aised. (new class-expr (id by-name-
- Page 291 and 292:
(let ([o edit]) (send o begin-edit-
- Page 293 and 294:
the exn:fail:contract exception is
- Page 295 and 296:
(trait trait-clause ...)) is equiva
- Page 297 and 298:
Produces a new trait that is like t
- Page 299 and 300:
Produces a contract for an object.
- Page 301 and 302:
id identifier is bound to the new c
- Page 303 and 304:
Returns #t if v is a generic, #f ot
- Page 305 and 306:
• class: a class or #f; the resul
- Page 307 and 308:
The host interface has the names se
- Page 309 and 310:
Each import or export sig-spec ulti
- Page 311 and 312:
When a define-signature form includ
- Page 313 and 314:
The unit produced by unit-expr is l
- Page 315 and 316:
tagged-infer-link-import = tagged-s
- Page 317 and 318:
6.5 Generating A Unit from Context
- Page 319 and 320:
substituted for a use of sig-form-i
- Page 321 and 322:
| (begin require-decl ...) | derive
- Page 323 and 324:
7 Contracts The contract system gua
- Page 325 and 326:
does not accept a function like thi
- Page 327 and 328:
Accepts any number of atomic values
- Page 329 and 330:
Constructs a recursive flat contrac
- Page 331 and 332:
mandatory-dom = dom-expr | keyword
- Page 333 and 334:
est = | #:rest rest-expr range = ra
- Page 335 and 336:
(cond [(null l) 1] [else (if (zero
- Page 337 and 338:
positions and the define/contract f
- Page 339 and 340:
val src-info pos name "expected , g
- Page 341 and 342:
must be guaranteed to fail the cont
- Page 343 and 344:
function contract). For example, fl
- Page 345 and 346:
8 Pattern Matching The match form a
- Page 347 and 348:
Examples: > (match ’(1 2 3) [(lis
- Page 349 and 350:
Examples: > (match #hash(("a". 1) (
- Page 351 and 352:
(match ’(1 2) [(or (list a 1) (li
- Page 353 and 354:
2 (exn:misc:match v) → boolean v
- Page 355 and 356:
Whenever a primitive error occurs i
- Page 357 and 358:
and all of the original arguments v
- Page 359 and 360:
eturns a value when invoked by rais
- Page 361 and 362:
proc : (string any/c . -> . any) A
- Page 363 and 364:
Raised for errors from the inapprop
- Page 365 and 366:
printer does not show the program c
- Page 367 and 368:
(promise-forced promise) → boolea
- Page 369 and 370:
Creates a prompt tag that is not eq
- Page 371 and 372:
(let/ec k body ...+) Equivalent to
- Page 373 and 374:
(let ([v (let/ec out (dynamic-wind
- Page 375 and 376:
Like prompt and control, but using
- Page 377 and 378:
(control0-at tag k (proc k))))) (pr
- Page 379 and 380:
(continuation-marks cont [prompt-ta
- Page 381 and 382:
(continuation-mark-set->context mar
- Page 383 and 384:
code is executed, (with-handlers ([
- Page 385 and 386:
10 Concurrency PLT Scheme supports
- Page 387 and 388:
exception is raised, and the thread
- Page 389 and 390:
(thread-resume-evt thd) → evt thd
- Page 391 and 392:
• semaphore — a semaphore is re
- Page 393 and 394:
• struct — a structure whose ty
- Page 395 and 396:
procedure receives an event that be
- Page 397 and 398:
(current-evt-pseudo-random-generato
- Page 399 and 400:
nal counter has already reached its
- Page 401 and 402:
(async-channel-try-get ach) → any
- Page 403 and 404:
(channel-get ch) (nerve) > (channel
- Page 405 and 406:
(let ([k (let/cc out (parameterize
- Page 407 and 408:
Returns #t if v is a parameterizati
- Page 409 and 410:
_ A _ pattern (i.e., an identifier
- Page 411 and 412:
Matches the same as stat-pattern, w
- Page 413 and 414:
• If the sub-template is replicat
- Page 415 and 416:
(syntax-rules (literal-id ...) [(id
- Page 417 and 418:
Returns the character position (pos
- Page 419 and 420:
srcloc : (or/c syntax #f (list/c an
- Page 421 and 422:
provide, or due to a transformer bi
- Page 423 and 424:
→ (or/c ’lexical #f (listof mod
- Page 425 and 426:
the integer must be between 0 (incl
- Page 427 and 428:
might introduce bindings or referen
- Page 429 and 430:
clude the definitions. After discov
- Page 431 and 432:
Like syntax-local-value, but the re
- Page 433 and 434:
definition contexts that are still
- Page 435 and 436:
the same mark, and different result
- Page 437 and 438:
property implements a derived requi
- Page 439 and 440:
sub-forms, so that expand-import ca
- Page 441 and 442:
Binds id as syntax to a syntax para
- Page 443 and 444:
form’s bound variables is evaluat
- Page 445 and 446:
for information about properties re
- Page 447 and 448:
• If the result has no ’certify
- Page 449 and 450:
Before top-level-form is expanded,
- Page 451 and 452:
it is not #f, or relative to (curre
- Page 453 and 454:
codings. See also reencode-input-po
- Page 455 and 456:
(current-input-port) → input-port
- Page 457 and 458:
Gets or sets the buffer mode for po
- Page 459 and 460:
(port-count-lines-enabled) → bool
- Page 461 and 462:
• ’append — append to the end
- Page 463 and 464:
(with-input-from-file path thunk [#
- Page 465 and 466:
position is unchanged. The start-po
- Page 467 and 468:
(make-input-port name read-in peek
- Page 469 and 470:
If peek, get-progress-evt, and comm
- Page 471 and 472:
- It must not block indefinitely if
- Page 473 and 474:
; we’d run out of memory. ; An in
- Page 475 and 476:
(define (make-mod3-cycle) (define r
- Page 477 and 478:
write-out : (bytes exact-nonnegativ
- Page 479 and 480:
The result should never be 0 if the
- Page 481 and 482:
If it is a procedure, it takes one
- Page 483 and 484:
(display "hello" accumulator) > acc
- Page 485 and 486:
separator : any/c = #"\n" Use displ
- Page 487 and 488:
(make-input-port/read-to-peek name
- Page 489 and 490:
(make-pipe-with-specials [limit in-
- Page 491 and 492:
(reencode-output-port out encoding
- Page 493 and 494:
(relocate-output-port out line colu
- Page 495 and 496:
str : (and/c bytes (not/c immutable
- Page 497 and 498:
ytes from the port might contribute
- Page 499 and 500:
Return and linefeed characters are
- Page 501 and 502:
→ (or/c exact-nonnegative-integer
- Page 503 and 504:
→ (or/c exact-nonnegative-integer
- Page 505 and 506:
(peek-byte-or-special [in skip-byte
- Page 507 and 508:
(write-string str [out start-pos en
- Page 509 and 510:
(write-bytes-avail-evt bstr [out st
- Page 511 and 512:
ead/recursive with a character and
- Page 513 and 514:
A parameter that controls whether [
- Page 515 and 516:
A parameter whose value determines
- Page 517 and 518:
datum : any/c out : output-port = (
- Page 519 and 520:
Examples: > (fprintf (current-outpu
- Page 521 and 522:
(print-honu on) → void on : any/c
- Page 523 and 524:
insensitivity is enabled); the subs
- Page 525 and 526:
12.6.3 Reading Numbers A sequence t
- Page 527 and 528:
If the reader finds three or more d
- Page 529 and 530:
includes all characters between the
- Page 531 and 532:
#(1 apple 3) reads equal to (vector
- Page 533 and 534:
• #\u〈digit 16 〉 {1,4} : like
- Page 535 and 536:
e followed by a single space (ASCII
- Page 537 and 538:
A positive, exact integer prints as
- Page 539 and 540:
12.7.8 Printing Hash Tables When th
- Page 541 and 542:
Same as pretty-print, but v is prin
- Page 543 and 544:
(pretty-print-extend-style-table st
- Page 545 and 546:
The default proc procedure prints a
- Page 547 and 548:
ducing output. Use such a port to t
- Page 549 and 550:
key : (or/c character #f) mode : (o
- Page 551 and 552:
; Provides raise-read-error and rai
- Page 553 and 554:
(define parse-open-tuple (case-lamb
- Page 555 and 556:
Returns the value encapsulated by t
- Page 557 and 558:
(serialize v) → any v : serializa
- Page 559 and 560:
The #f-filled value will be updated
- Page 561 and 562:
A parameter whose value is called b
- Page 563 and 564:
is normally tied to a particular st
- Page 565 and 566:
13 Reflection and Security 13.1 Nam
- Page 567 and 568:
(namespace-module-identifier [where
- Page 569 and 570:
quoted-raw-require-spec : any/c Lik
- Page 571 and 572:
context is overridden by any existi
- Page 573 and 574:
namespace-syntax-introduce to the (
- Page 575 and 576:
(load/cd file) → any file : path-
- Page 577 and 578:
Starts a new REPL using the current
- Page 579 and 580:
(compile-enforce-module-constants o
- Page 581 and 582:
Since all forms within a scheme/loa
- Page 583 and 584:
For the second case, the standard m
- Page 585 and 586:
Returns two values: a module path,
- Page 587 and 588:
See also module->language-info. 13.
- Page 589 and 590:
The file-guard procedure must accep
- Page 591 and 592:
(custodian-shutdown-all cust) → v
- Page 593 and 594:
elongs to a thread group, which is
- Page 595 and 596:
→ symbol exact-nonnegative-intege
- Page 597 and 598:
• the use of module->namespace on
- Page 599 and 600:
The returned evaluator function acc
- Page 601 and 602:
The sandboxed evironment is well is
- Page 603 and 604:
to the language; the hook is used a
- Page 605 and 606:
Like sandbox-output, but for the in
- Page 607 and 608:
paths and access modes that are all
- Page 609 and 610:
limits : (or/c (list/c (or/c nonneg
- Page 611 and 612:
13.10.2 Interacting with Evaluators
- Page 613 and 614:
(get-uncovered-expressions evaluato
- Page 615 and 616:
(exn:fail:resource v) → boolean v
- Page 617 and 618:
(path-for-some-system v) → boolea
- Page 619 and 620:
OS X Paths” for more information
- Page 621 and 622:
Like build-path, except a path conv
- Page 623 and 624:
eturned; if path is relative, it is
- Page 625 and 626:
Similar to path-replace-suffix, but
- Page 627 and 628:
14.1.3 Unix and Mac OS X Paths In U
- Page 629 and 630:
\s can appear in place of the \ bef
- Page 631 and 632:
or \\\RED\ sub-path) is simplified
- Page 633 and 634:
• ’run-file — the path of the
- Page 635 and 636:
path : path-string Deletes the file
- Page 637 and 638:
A parameter that determines the cur
- Page 639 and 640:
For compile-time, the expr result i
- Page 641 and 642:
module must require (directly or in
- Page 643 and 644:
(display-lines-to-file lst path [#:
- Page 645 and 646:
current directory. Otherwise, the f
- Page 647 and 648:
(put-preferences names vals [locked
- Page 649 and 650:
hostname : string port-no : (and/c
- Page 651 and 652:
Tests whether an unaccepted client
- Page 653 and 654:
determined from these arguments. Th
- Page 655 and 656:
the connection target. If udp-socke
- Page 657 and 658:
udp-socket : udp bstr : (and/c byte
- Page 659 and 660:
Returns a synchronizable event. The
- Page 661 and 662:
• an input port piped from the pr
- Page 663 and 664:
• ’sw_maximize or ’SW_MAXIMIZ
- Page 665 and 666:
• an input port piped from the su
- Page 667 and 668:
(see §1.1.7 “Garbage Collection
- Page 669 and 670:
marks are sent to the logger with t
- Page 671 and 672:
See also the scheme/date library. (
- Page 673 and 674:
(find-seconds second minute hour da
- Page 675 and 676:
(system-language+country) → strin
- Page 677 and 678:
For thread-specific statistics, up
- Page 679 and 680:
that start with - or + are not trea
- Page 681 and 682:
[("-p" "--profile") "Compile with p
- Page 683 and 684:
The following example is the same a
- Page 685 and 686:
In particular, an ephemeron can be
- Page 687 and 688:
Forces an immediate garbage collect
- Page 689 and 690:
the command line is started, MzSche
- Page 691 and 692:
- -I 〈path〉 : Sets (lib "〈pat
- Page 693 and 694:
Other collections are distributed w
- Page 695 and 696:
16.3 Interactive Help (require sche
- Page 697 and 698:
When it loads or re-loads a module
- Page 699 and 700:
Index ", 527 #! , 530 #!, 535 #!/,
- Page 701 and 702:
\e, 528 \f, 528 \n, 528 \r, 528 \t,
- Page 703 and 704:
ytes-set!, 151 bytes-utf-8-index, 1
- Page 705 and 706:
"COM9", 628 combine-in, 49 combine-
- Page 707 and 708:
custom-write-accessor, 556 custom-w
- Page 709 and 710:
equal-hash-code, 225 equal-secondar
- Page 711 and 712:
file-or-directory-modify-seconds, 6
- Page 713 and 714:
import-req-mode, 437 import-source,
- Page 715 and 716:
List Filtering, 194 List Iteration,
- Page 717 and 718:
make-set!-transformer, 424 make-sib
- Page 719 and 720:
namespace-variable-value, 567 names
- Page 721 and 722:
Phases, 24 phases, 24 pi, 136 ’pi
- Page 723 and 724:
prop:rename-transformer, 426 prop:r
- Page 725 and 726:
Regular expressions, 170 ’relativ
- Page 727 and 728:
set-mcdr!, 211 seventh, 202 sgn, 13
- Page 729 and 730:
struct:exn:fail:read:non-char, 364
- Page 731 and 732:
system-path-convention-type, 619 sy
- Page 733 and 734:
variable-reference->emptynamespace,