Skip to content

Commit

Permalink
move sequence/c into the part of the docs for racket/sequence
Browse files Browse the repository at this point in the history
  • Loading branch information
rfindler committed Mar 5, 2015
1 parent 30610ba commit 0c2ca96
Showing 1 changed file with 39 additions and 42 deletions.
81 changes: 39 additions & 42 deletions pkgs/racket-doc/scribblings/reference/sequences.scrbl
Original file line number Diff line number Diff line change
Expand Up @@ -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},
Expand All @@ -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
Expand Down Expand Up @@ -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]

Expand Down Expand Up @@ -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}

Expand Down

0 comments on commit 0c2ca96

Please sign in to comment.