dic docs for 'do' (PR 9640)

svn: r10970
This commit is contained in:
Matthew Flatt 2008-07-29 19:23:38 +00:00
parent 316ee3180d
commit 1ca888a934
3 changed files with 23 additions and 11 deletions

View File

@ -312,29 +312,28 @@ parallel iterations.}
@section{Do Loops} @section{Do Loops}
@defform/subs[(do ([id init-expr step-expr-maybe] ...) @defform/subs[(do ([id init-expr step-expr-maybe] ...)
(cont?-expr finish-expr ...) (stop?-expr finish-expr ...)
expr ...+) expr ...+)
([step-expr-maybe code:blank ([step-expr-maybe code:blank
step-expr])]{ step-expr])]{
Iteratively evaluates the @scheme[expr]s for as long as Iteratively evaluates the @scheme[expr]s for as long as
@scheme[cont-expr?] returns @scheme[#t]. @scheme[stop-expr?] returns @scheme[#f].
To initialize the loop, the @scheme[init-expr]s are evaluated in order To initialize the loop, the @scheme[init-expr]s are evaluated in order
and bound to the corresponding @scheme[id]s. The @scheme[id]s are and bound to the corresponding @scheme[id]s. The @scheme[id]s are
bound in all expressions within the form other than the bound in all expressions within the form other than the
@scheme[init-expr]s. @scheme[init-expr]s.
After he @scheme[id]s are bound, then @scheme[cont?-expr] is After he @scheme[id]s are bound, then @scheme[stop?-expr] is
evaluated. If it produces a true value, then each @scheme[expr] is evaluated. If it produces @scheme[#f], each @scheme[expr] is evaluated
evaluated for its side-effect. The @scheme[id]s are then updated with for its side-effect. The @scheme[id]s are then updated with the values
the values of the @scheme[step-expr]s, where the default of the @scheme[step-expr]s, where the default @scheme[step-expr] for
@scheme[step-expr] for @scheme[id] is just @scheme[id]. Iteration @scheme[id] is just @scheme[id]. Iteration continues by evaluating
continues by evaluating @scheme[cont?-expr]. @scheme[cont?-expr].
When @scheme[cont?-expr] produces @scheme[#f], then the When @scheme[stop?-expr] produces a true value, then the
@scheme[finish-expr]s are evaluated in order, and the last one is @scheme[finish-expr]s are evaluated in order, and the last one is
evaluated in tail position to produce the overall value for the evaluated in tail position to produce the overall value for the
@scheme[do] form. If no @scheme[finish-expr] is provided, the value of @scheme[do] form. If no @scheme[finish-expr] is provided, the value of
the @scheme[do] form is @|void-const|.} the @scheme[do] form is @|void-const|.}

View File

@ -569,6 +569,15 @@ produces @scheme[+nan.0] in the case that neither @scheme[y] nor
@examples[(bitwise-not 5) (bitwise-not -1)]} @examples[(bitwise-not 5) (bitwise-not -1)]}
@defproc[(bitwise-bit-set? [n exact-integer?] [m exact-nonnegative-integer?])
boolean?]{
Returns @scheme[(not (zero? (bitwise-and n (arithmetic-shift 1 m))))],
but normally without allocating intermediate results.
@examples[(bitwise-bit-set? 5 0) (bitwise-bit-set? 5 2) (bitwise-bit-set? -5 (expt 2 700))]}
@defproc[(arithmetic-shift [n exact-integer?] [m exact-integer?]) @defproc[(arithmetic-shift [n exact-integer?] [m exact-integer?])
exact-integer?]{ Returns the bitwise ``shift'' of @scheme[n] in its exact-integer?]{ Returns the bitwise ``shift'' of @scheme[n] in its
(semi-infinite) two's complement representation. If @scheme[m] is (semi-infinite) two's complement representation. If @scheme[m] is
@ -579,7 +588,6 @@ produces @scheme[+nan.0] in the case that neither @scheme[y] nor
@examples[(arithmetic-shift 1 10) (arithmetic-shift 255 -3)]} @examples[(arithmetic-shift 1 10) (arithmetic-shift 255 -3)]}
@defproc[(integer-length [n exact-integer?]) exact-integer?]{ Returns @defproc[(integer-length [n exact-integer?]) exact-integer?]{ Returns
the number of bits in the (semi-infinite) two's complement the number of bits in the (semi-infinite) two's complement
representation of @scheme[n] after removing all leading zeros (for representation of @scheme[n] after removing all leading zeros (for

View File

@ -122,6 +122,11 @@ its value from @scheme[hash] (as opposed to using @scheme[hash] directly
as a sequence to get the key and value as separate values for each as a sequence to get the key and value as separate values for each
element).} element).}
@defproc[(in-value [v any/c]) sequence]{
Returns a sequence that produces a single value: @scheme[v]. This form
is mostly useful for @scheme[let]-like bindings in forms such as
@scheme[for*/list].}
@defproc[(in-indexed [seq sequence?]) sequence?]{Returns a sequence @defproc[(in-indexed [seq sequence?]) sequence?]{Returns a sequence
where each element has two values: the value produced by @scheme[seq], where each element has two values: the value produced by @scheme[seq],
and a non-negative exact integer starting with @scheme[0]. The and a non-negative exact integer starting with @scheme[0]. The