{"size": 2009, "ext": "scrbl", "max_stars_repo_path": "collection/vector.scrbl", "max_stars_repo_name": "9999years/rebellion", "max_stars_repo_stars_event_min_datetime": "2019-05-28T21:50:27.000Z", "max_stars_repo_stars_event_max_datetime": "2022-03-17T21:21:52.000Z", "max_issues_repo_path": "collection/vector.scrbl", "max_issues_repo_name": "9999years/rebellion", "max_issues_repo_issues_event_min_datetime": "2019-03-02T23:19:07.000Z", "max_issues_repo_issues_event_max_datetime": "2022-01-24T08:43:16.000Z", "max_forks_repo_path": "collection/vector.scrbl", "max_forks_repo_name": "9999years/rebellion", "max_forks_repo_forks_event_min_datetime": "2019-02-01T22:21:26.000Z", "max_forks_repo_forks_event_max_datetime": "2022-01-24T04:35:35.000Z"}
{"max_stars_count": 73, "max_issues_count": 216, "max_forks_count": 20, "avg_line_length": 35.2456140351, "max_line_length": 78, "alphanum_fraction": 0.6361373818}
#lang scribble/manual

@(require (for-label racket/base
                     racket/contract/base
                     racket/math
                     racket/sequence
                     rebellion/collection/immutable-vector
                     rebellion/collection/vector
                     rebellion/streaming/reducer
                     rebellion/streaming/transducer)
          (submod rebellion/private/scribble-cross-document-tech doc)
          (submod rebellion/private/scribble-evaluator-factory doc)
          scribble/example)

@(define make-evaluator
   (make-module-sharing-evaluator-factory
    #:public (list 'rebellion/collection/vector
                   'rebellion/streaming/transducer)
    #:private (list 'racket/base)))

@title{Vectors}
@defmodule[rebellion/collection/vector]

@defproc[(mutable-vector? [v any/c]) boolean?]{
 A predicate for mutable vectors. Implies @racket[vector?].}

@defproc[(into-vector [#:size size (or/c natural? +inf.0) +inf.0])
         (reducer/c any/c immutable-vector?)]{
 Constructs a @tech{reducer} that collects at most @racket[size] elements of a
 sequence into an immutable vector.

 @(examples
   #:eval (make-evaluator) #:once
   (transduce (in-naturals)
              (filtering odd?)
              #:into (into-vector #:size 5)))}

@defproc[(into-mutable-vector [#:size size (or/c natural? +inf.0) +inf.0])
         (reducer/c any/c mutable-vector?)]{
 Constructs a @tech{reducer} that collects at most @racket[size] elements of a
 sequence into a mutable vector.

 @(examples
   #:eval (make-evaluator) #:once
   (transduce (in-naturals)
              (filtering even?)
              #:into (into-mutable-vector #:size 5)))}

@defproc[(sequence->vector [seq (sequence/c any/c)]) immutable-vector?]{
 Copies @racket[seq] into an immutable vector. If @racket[seq] is already an
 immutable vector, it is returned directly.

 @(examples
   #:eval (make-evaluator) #:once
   (sequence->vector (list 1 2 3))
   (sequence->vector (in-range 0 10)))}
