Several typos from Jussi Salmela. Fixes PR 11790 -- all typos.
(Two issues remain that will be resolved later.)
This commit is contained in:
parent
a18197ff25
commit
5a9d954f2a
|
@ -19,7 +19,7 @@ many kinds of values, notably strings and lists, each @racket[_datum]
|
|||
is typically a number, symbol, or boolean.
|
||||
|
||||
Multiple @racket[_datum]s can be supplied for each clause, and the
|
||||
corresponding @racket[_expr] is evaluated of any of the
|
||||
corresponding @racket[_expr] is evaluated if any of the
|
||||
@racket[_datum]s match.
|
||||
|
||||
@examples[
|
||||
|
|
|
@ -213,7 +213,7 @@ put the optional ones in the second section.
|
|||
A function defined with @racket[case-lambda] might impose different
|
||||
constraints on its arguments depending on how many are provided. For
|
||||
example, a @racket[report-cost] function might convert either a pair
|
||||
or numbers or a string into a new string:
|
||||
of numbers or a string into a new string:
|
||||
|
||||
@margin-note{See @secref["case-lambda"] for an introduction to
|
||||
@racket[case-lambda].}
|
||||
|
@ -297,7 +297,7 @@ section of the reference manual. They simplify contracts tremendously
|
|||
and make them more accessible to potential clients.
|
||||
}
|
||||
|
||||
Going back to the back-account example, suppose that we generalize the
|
||||
Going back to the bank-account example, suppose that we generalize the
|
||||
module to support multiple accounts and that we also include a
|
||||
withdrawal operation. The improved bank-account module includes a
|
||||
@racket[account] structure type and the following functions:
|
||||
|
|
|
@ -201,7 +201,7 @@ values to flow in both directions.
|
|||
|
||||
@ctc-section{Experimenting with Contracts and Modules}
|
||||
|
||||
All of the contracts and module in this chapter (excluding those just
|
||||
All of the contracts and modules in this chapter (excluding those just
|
||||
following) are written using the standard @tt{#lang} syntax for
|
||||
describing modules. Since modules serve as the boundary between
|
||||
parties in a contract, examples involve multiple modules.
|
||||
|
|
|
@ -174,7 +174,7 @@ racket
|
|||
(define (balance) amount)
|
||||
]
|
||||
|
||||
This module define an @racket[amount?] function as uses it as a
|
||||
This module defines an @racket[amount?] function and uses it as a
|
||||
contract within @racket[->] contracts. When a client calls the
|
||||
@racket[deposit] function as exported with the contract @racket[(->
|
||||
amount? any)], it must supply an exact, nonnegative integer, otherwise
|
||||
|
@ -292,9 +292,8 @@ racket
|
|||
....
|
||||
(code:comment "convert an amount (natural number) of cents")
|
||||
(code:comment "into a dollar based string")
|
||||
[format-nat (-> natural-number/c
|
||||
(and/c string?
|
||||
#rx"[0-9]*\\.[0-9][0-9][0-9]"))])
|
||||
[format-nat (-> natural-number/c
|
||||
(and/c string? #rx"[0-9]*\\.[0-9][0-9]"))])
|
||||
]
|
||||
|
||||
@; ------------------------------------------------------------------------
|
||||
|
@ -328,7 +327,7 @@ describes functions that accept other functions as its input. If a
|
|||
server exports a function @racket[twice] with this contract and the
|
||||
@racket[twice] is applied to a value other than a function of one
|
||||
argument, then the client is to blame. If @racket[twice] is applied to
|
||||
a function of one argument and @racket[twice] calls the give function
|
||||
a function of one argument and @racket[twice] calls the given function
|
||||
on a value other than an integer, then the server is to blame.
|
||||
|
||||
@; ----------------------------------------------------------------------
|
||||
|
|
|
@ -262,7 +262,7 @@ Here are some examples using each:
|
|||
|
||||
]
|
||||
|
||||
Overall, @racket[print] as corresponds to the expression layer of
|
||||
Overall, @racket[print] corresponds to the expression layer of
|
||||
Racket syntax, @racket[write] corresponds to the reader layer, and
|
||||
@racket[display] roughly corresponds to the character layer.
|
||||
|
||||
|
@ -294,7 +294,9 @@ After using @racket[write], as opposed to @racket[display] or
|
|||
(read in)
|
||||
(write #hash((a . "apple") (b . "banana")) out)
|
||||
(read in)
|
||||
(write '("alphabet" soup) out)
|
||||
(print '("alphabet" soup) out)
|
||||
(read in)
|
||||
(display '("alphabet" soup) out)
|
||||
(read in)
|
||||
]
|
||||
|
||||
|
@ -315,7 +317,7 @@ Other structure types created by @racket[struct], which offer
|
|||
more abstraction than @tech{prefab} structure types, normally
|
||||
@racket[write] either using @racketresultfont{#<....>} notation (for
|
||||
opaque structure types) or using @racketresultfont{#(....)} vector
|
||||
notation (for transparent structure types). In neither can can the
|
||||
notation (for transparent structure types). In neither can the
|
||||
result be read back in as an instance of the structure type:
|
||||
|
||||
@interaction[
|
||||
|
|
|
@ -105,7 +105,7 @@ identifier and a default value:
|
|||
[arg-id default-expr]])
|
||||
]{}
|
||||
|
||||
A argument of the form @racket[[arg-id default-expr]] is
|
||||
An argument of the form @racket[[arg-id default-expr]] is
|
||||
optional. When the argument is not supplied in an application,
|
||||
@racket[_default-expr] produces the default value. The
|
||||
@racket[_default-expr] can refer to any preceding @racket[_arg-id],
|
||||
|
|
|
@ -117,12 +117,12 @@ list loops.
|
|||
Racket provides a general @defterm{list comprehension} form
|
||||
@racket[for/list], which builds a list by iterating through
|
||||
@defterm{sequences}. List comprehensions and related iteration forms
|
||||
are described in see @secref["for"].
|
||||
are described in @secref["for"].
|
||||
|
||||
@;------------------------------------------------------------------------
|
||||
@section{List Iteration from Scratch}
|
||||
|
||||
Although @racket[map] and other iteration functions predefined, they
|
||||
Although @racket[map] and other iteration functions are predefined, they
|
||||
are not primitive in any interesting sense. You can write equivalent
|
||||
iterations using a handful of list primitives.
|
||||
|
||||
|
|
|
@ -115,4 +115,4 @@ Equivalently, the @racket[prefix-in] could be applied before
|
|||
@racket[except-in], as long as the omission with @racket[except-in] is
|
||||
specified using the @racket[m:] prefix:
|
||||
|
||||
@racketblock[(require (except-in (prefix m: 'm) m:ghost))]
|
||||
@racketblock[(require (except-in (prefix-in m: 'm) m:ghost))]
|
||||
|
|
|
@ -132,7 +132,7 @@ to adjust its value:
|
|||
(and (not (equal? lokation "here"))
|
||||
(not (equal? lokation "there"))))
|
||||
|
||||
(set! location "on a bus")
|
||||
(set! lokation "on a bus")
|
||||
(would-ya-could-ya?)
|
||||
]
|
||||
|
||||
|
|
|
@ -139,14 +139,19 @@ effectively cancels one layer of @racket[unquote] and
|
|||
or @racket[unquote-splicing] is needed.
|
||||
|
||||
@examples[
|
||||
(eval:alts (#,qq (1 2 (#,qq (#,uq (+ 1 2)
|
||||
(#,uq (#,uq (- 5 1)))))))
|
||||
`(1 2 (,(string->uninterned-symbol "quasiquote")
|
||||
(,(string->uninterned-symbol "unquote") (+ 1 2))
|
||||
(,(string->uninterned-symbol "unquote") 4))))
|
||||
(eval:alts (#,qq (1 2 (#,qq (#,uq (+ 1 2)))))
|
||||
`(1 2 (,(string->uninterned-symbol "quasiquote")
|
||||
(,(string->uninterned-symbol "unquote") (+ 1 2)))))
|
||||
(eval:alts (#,qq (1 2 (#,qq (#,uq (#,uq (+ 1 2))))))
|
||||
`(1 2 (,(string->uninterned-symbol "quasiquote")
|
||||
(,(string->uninterned-symbol "unquote") 3))))
|
||||
(eval:alts (#,qq (1 2 (#,qq ((#,uq (+ 1 2)) (#,uq (#,uq (- 5 1)))))))
|
||||
`(1 2 (,(string->uninterned-symbol "quasiquote")
|
||||
((,(string->uninterned-symbol "unquote") (+ 1 2))
|
||||
(,(string->uninterned-symbol "unquote") 4)))))
|
||||
]
|
||||
|
||||
The evaluation above will not actually print as shown. Instead, the
|
||||
The evaluations above will not actually print as shown. Instead, the
|
||||
shorthand form of @racket[quasiquote] and @racket[unquote] will be
|
||||
used: @litchar{`} (i.e., a backquote) and @litchar{,} (i.e., a comma).
|
||||
The same shorthands can be used in expressions:
|
||||
|
|
|
@ -383,7 +383,7 @@ supported are
|
|||
|
||||
@item{@litchar{[:upper:]} --- ASCII upper-case letters}
|
||||
|
||||
@item{@litchar{[:word:]} --- ASCII same as @litchar{\w}}
|
||||
@item{@litchar{[:word:]} --- ASCII letters and @litchar{_}, same as @litchar{\w}}
|
||||
|
||||
@item{@litchar{[:xdigit:]} --- ASCII hex digits}
|
||||
|
||||
|
@ -581,15 +581,6 @@ no problem doing so:
|
|||
"billions and millions")
|
||||
]
|
||||
|
||||
The following example corrects doubled words:
|
||||
|
||||
@interaction[
|
||||
(regexp-replace* #px"(\\S+) \\1"
|
||||
(string-append "now is the the time for all good men to "
|
||||
"to come to the aid of of the party")
|
||||
"\\1")
|
||||
]
|
||||
|
||||
The following example marks all immediately repeating patterns in a
|
||||
number string:
|
||||
|
||||
|
@ -599,6 +590,15 @@ number string:
|
|||
"{\\1,\\1}")
|
||||
]
|
||||
|
||||
The following example corrects doubled words:
|
||||
|
||||
@interaction[
|
||||
(regexp-replace* #px"\\b(\\S+) \\1\\b"
|
||||
(string-append "now is the the time for all good men to "
|
||||
"to come to the aid of of the party")
|
||||
"\\1")
|
||||
]
|
||||
|
||||
@subsection{Non-capturing Clusters}
|
||||
|
||||
It is often required to specify a cluster (typically for
|
||||
|
@ -893,15 +893,14 @@ three dots separating them.
|
|||
#:eval ex-eval
|
||||
(define ip-re1
|
||||
(string-append
|
||||
"^" (code:comment @#,t{nothing before})
|
||||
n0-255 (code:comment @#,t{the first @racket[n0-255],})
|
||||
"(?:" (code:comment @#,t{then the subpattern of})
|
||||
"\\." (code:comment @#,t{a dot followed by})
|
||||
n0-255 (code:comment @#,t{an @racket[n0-255],})
|
||||
")" (code:comment @#,t{which is})
|
||||
"{3}" (code:comment @#,t{repeated exactly 3 times})
|
||||
"$" (code:comment @#,t{with nothing following})
|
||||
))
|
||||
"^" (code:comment @#,t{nothing before})
|
||||
n0-255 (code:comment @#,t{the first @racket[n0-255],})
|
||||
"(?:" (code:comment @#,t{then the subpattern of})
|
||||
"\\." (code:comment @#,t{a dot followed by})
|
||||
n0-255 (code:comment @#,t{an @racket[n0-255],})
|
||||
")" (code:comment @#,t{which is})
|
||||
"{3}" (code:comment @#,t{repeated exactly 3 times})
|
||||
"$")) (code:comment @#,t{with nothing following})
|
||||
]
|
||||
|
||||
Let's try it out:
|
||||
|
|
|
@ -18,7 +18,7 @@ For any sequence of characters, exactly one corresponding symbol is
|
|||
@defterm{interned}; calling the @racket[string->symbol] procedure, or
|
||||
@racket[read]ing a syntactic identifier, produces an interned
|
||||
symbol. Since interned symbols can be cheaply compared with
|
||||
@racket[eq?] (and thus @racket[eqv?] or @racket[equal?]), they serves
|
||||
@racket[eq?] (and thus @racket[eqv?] or @racket[equal?]), they serve
|
||||
as a convenient values to use for tags and enumerations.
|
||||
|
||||
Symbols are case-sensitive. By using a @racketfont{#ci} prefix or in
|
||||
|
|
Loading…
Reference in New Issue
Block a user