[racket] Bug in TR for/sum: ??

From: Sam Tobin-Hochstadt (samth at ccs.neu.edu)
Date: Thu Mar 28 16:04:50 EDT 2013

On Thu, Mar 28, 2013 at 4:03 PM, Sam Tobin-Hochstadt <samth at ccs.neu.edu> wrote:
> I'm not sure what you're referring to. This program doesn't typecheck,
> because if both vectors were empty, the result is exact 0, which isn't
> a `Float`.

Oh, and here's a working version using `for/fold:`:

#lang typed/racket/base

(define: βns : (Vectorof Float) '#(1.0 2.0 3.0))
(define: χns : (Vectorof Float) '#(4.0 5.0 6.0))

(for/fold: : Float
  ([s : Float 0.0])
  ([βn : Float (in-vector βns)]
   [χn : Float (in-vector χns)])
  (+ s (* βn χn)))

Sam

> On Thu, Mar 28, 2013 at 3:56 PM, Ray Racine <ray.racine at gmail.com> wrote:
>> Is this a bug?
>>
>> #lang typed/racket/base
>>
>> (define: βns : (Vectorof Float) '#(1.0 2.0 3.0))
>> (define: χns : (Vectorof Float) '#(4.0 5.0 6.0))
>>
>> (for/sum: : Float
>>   ([βn : Float (in-vector βns)]
>>    [χn : Float (in-vector χns)])
>>   (* βn χn))
>>
>> ____________________
>>   Racket Users list:
>>   http://lists.racket-lang.org/users
>>


Posted on the users mailing list.