move sequence/c into the part of the docs for racket/sequence

This commit is contained in:
Robby Findler 2015-03-05 08:26:54 -06:00
parent 30610babe3
commit 0c2ca96ad2

View File

@ -146,7 +146,7 @@ example, a hash table generates two values---a key and its value---for
each element in the sequence.
@; ----------------------------------------------------------------------
@subsection{Sequence Predicate and Contract}
@subsection{Sequence Predicate and Constructors}
@defproc[(sequence? [v any/c]) boolean?]{
Returns @racket[#t] if @racket[v] can be used as a @tech{sequence},
@ -158,46 +158,6 @@ each element in the sequence.
(sequence? "word")
(sequence? #\x)]}
@defproc[(sequence/c [#:min-count min-count (or/c #f exact-nonnegative-integer?) #f]
[elem/c contract?] ...)
contract?]{
Wraps a @tech{sequence},
obligating it to produce as many values as there are @racket[elem/c] contracts,
and obligating each value to satisfy the corresponding @racket[elem/c]. The
result is not guaranteed to be the same kind of sequence as the original value;
for instance, a wrapped list is not guaranteed to satisfy @racket[list?].
If @racket[min-count] is a number, the stream is required to have at least that many elements in it.
@defexamples[
#:eval sequence-evaluator
(define/contract predicates
(sequence/c (-> any/c boolean?))
(in-list (list integer?
string->symbol)))
(for ([P predicates])
(printf "~s\n" (P "cat")))
(define/contract numbers&strings
(sequence/c number? string?)
(in-dict (list (cons 1 "one")
(cons 2 "two")
(cons 3 'three))))
(for ([(N S) numbers&strings])
(printf "~s: ~a\n" N S))
(define/contract a-sequence
(sequence/c #:min-count 2 char?)
"x")
(for ([x a-sequence]
[i (in-naturals)])
(printf "~a is ~a\n" i x))
]
}
@subsection{Sequence Constructors}
@defproc*[([(in-range [end number?]) stream?]
[(in-range [start number?] [end number?] [step number? 1]) stream?])]{
Returns a sequence (that is also a @tech{stream}) whose elements are
@ -654,7 +614,7 @@ If @racket[min-count] is a number, the stream is required to have at least that
values in the sequence), the @exnraise[exn:fail:contract].}
@; ----------------------------------------------------------------------
@subsection[#:tag "more-sequences"]{Sequence Combinations}
@subsection[#:tag "more-sequences"]{Sequence Combinations & Contract}
@note-lib[racket/sequence]
@ -783,6 +743,43 @@ If @racket[min-count] is a number, the stream is required to have at least that
]
}
@defproc[(sequence/c [#:min-count min-count (or/c #f exact-nonnegative-integer?) #f]
[elem/c contract?] ...)
contract?]{
Wraps a @tech{sequence},
obligating it to produce as many values as there are @racket[elem/c] contracts,
and obligating each value to satisfy the corresponding @racket[elem/c]. The
result is not guaranteed to be the same kind of sequence as the original value;
for instance, a wrapped list is not guaranteed to satisfy @racket[list?].
If @racket[min-count] is a number, the stream is required to have at least that many elements in it.
@defexamples[
#:eval sequence-evaluator
(define/contract predicates
(sequence/c (-> any/c boolean?))
(in-list (list integer?
string->symbol)))
(for ([P predicates])
(printf "~s\n" (P "cat")))
(define/contract numbers&strings
(sequence/c number? string?)
(in-dict (list (cons 1 "one")
(cons 2 "two")
(cons 3 'three))))
(for ([(N S) numbers&strings])
(printf "~s: ~a\n" N S))
(define/contract a-sequence
(sequence/c #:min-count 2 char?)
"x")
(for ([x a-sequence]
[i (in-naturals)])
(printf "~a is ~a\n" i x))
]
}
@; ======================================================================
@section[#:tag "streams"]{Streams}