[racket] TR+plot exposes idx9, idx54, etc?

 From: John Clements (clements at brinckerhoff.org) Date: Tue Apr 8 16:21:43 EDT 2014 Previous message: [racket] TR+plot exposes idx9, idx54, etc? Next message: [racket] TR+plot exposes idx9, idx54, etc? Messages sorted by: [date] [thread] [subject] [author]

```On Apr 8, 2014, at 12:04 PM, John Clements <clements at brinckerhoff.org> wrote:

>
> On Apr 8, 2014, at 11:54 AM, Sam Tobin-Hochstadt <samth at cs.indiana.edu> wrote:
>
>> 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`.
>
> But… in-indexed produces a sequence of 2-value elements. I guess I can get it working with sequence-map:
>
> (plot (lines (sequence-map (lambda (a b) (vector b a))
>                           (in-indexed (in-array fft-maxes)))))
>
> BUT WAIT! no, that doesn’t work in the typed setting, because sequence-map’s type doesn’t work for 2-valued sequences. Back to square 1.

Got it… “in-values-sequence”.

John

>
>>
>>> 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`.
>
> Ah! I tried typed/plot, but not plot/typed.
>
> Many thanks.
>
> John
>

```

 Posted on the users mailing list. Previous message: [racket] TR+plot exposes idx9, idx54, etc? Next message: [racket] TR+plot exposes idx9, idx54, etc? Messages sorted by: [date] [thread] [subject] [author]