[plt-scheme] Yet another (I think) hopefully minor typed-scheme problem with Vectorof types

From: Anthony Cowley (acowley at seas.upenn.edu)
Date: Tue Oct 27 11:50:26 EDT 2009

Hi Scott,

On Tue, Oct 27, 2009 at 7:36 AM, Scott McLoughlin <scott at adrenaline.com> wrote:
> Much better would be the addition of a simple function:
>   (define (a) (vector-copy [src : (Vectorof a)]) : (Vectorof a)

You should be able to roll your own to meet your exact needs in this
situation. The one tricky part would be if you wanted static bounds
checking as well, which would require just a skosh of extra work ;)

#lang typed-scheme

(: vcopy (∀ (a) ((Vectorof a) -> (Vectorof a))))
(define (vcopy v) (build-vector (vector-length v)
                                (λ:([i : Number]) (vector-ref v i))))


Posted on the users mailing list.