From 0c2ca96ad26babb784cbf988caba854641c6ee49 Mon Sep 17 00:00:00 2001 From: Robby Findler Date: Thu, 5 Mar 2015 08:26:54 -0600 Subject: [PATCH] move sequence/c into the part of the docs for racket/sequence --- .../scribblings/reference/sequences.scrbl | 81 +++++++++---------- 1 file changed, 39 insertions(+), 42 deletions(-) diff --git a/pkgs/racket-doc/scribblings/reference/sequences.scrbl b/pkgs/racket-doc/scribblings/reference/sequences.scrbl index 089f4f4ab9..4aa4527d8b 100644 --- a/pkgs/racket-doc/scribblings/reference/sequences.scrbl +++ b/pkgs/racket-doc/scribblings/reference/sequences.scrbl @@ -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}