[racket] TR+plot exposes idx9, idx54, etc?
On Tue, Apr 8, 2014 at 2:48 PM, John Clements <clements at brinckerhoff.org> wrote:
> Here’s a short piece of code that tries to plot an array:
>
> #lang typed/racket
>
> (require plot
> math/array)
>
> (define fft-maxes (array #[3.2 978.9 -2397]))
>
> (: with-indexes (Vectorof (Vector Nonnegative-Integer Real)))
> (define with-indexes
> (for/vector : (Vectorof (Vector Nonnegative-Integer Real))
> ([i : Nonnegative-Integer (in-naturals)]
> [a (in-array fft-maxes)])
> (ann (vector (ann i Nonnegative-Integer) a)
> (Vector Nonnegative-Integer Real))))
>
>
> (plot (lines (in-vector with-indexes)))
>
> I have two questions.
> 1) Is there an easier way to pair an array with indices? This was kind of challenging.
Try `in-indexed`.
> 2) When I run this, I get
>
> Type Checker: missing type for identifier;
> consider using `require/typed' to import it
> identifier: idX9
> from module: plot in: #%module-begin
> . Type Checker: missing type for identifier;
> consider using `require/typed' to import it
> identifier: idX54
> from module: plot/no-gui in: #%module-begin
> . Type Checker: Summary: 2 errors encountered in:
> #%module-begin
> #%module-begin
These are both from the use of `in-array` and/or `fft-maxes`, not from
your for loop. Probably the right thing is to use `plot/typed`.
Sam