<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta content="text/html;charset=ISO-8859-1" http-equiv="Content-Type">
</head>
<body bgcolor="#ffffff" text="#000000">
<small><tt><big><big>That did it - thanks a million! <br>
<br>
build-vector is sort of an untyped "enumerate" function already built<br>
into Scheme (is it part of the R5RS or R6RS standards?). Pretty cool!!!<br>
<br>
Scott<br>
</big></big></tt></small><br>
Carl Eastlund wrote:
<blockquote
cite="mid:990e0c030910241436j5552a27bk8101f9dd49082041@mail.gmail.com"
type="cite">
<pre wrap="">Scott,
It looks like you want build-vector rather than make-vector, for, and set!.
<a class="moz-txt-link-freetext" href="http://docs.plt-scheme.org/reference/vectors.html#(def._((lib._scheme/base..ss)._build-vector))">http://docs.plt-scheme.org/reference/vectors.html#(def._((lib._scheme/base..ss)._build-vector))</a>
--Carl
On Sat, Oct 24, 2009 at 5:31 PM, Scott McLoughlin <a class="moz-txt-link-rfc2396E" href="mailto:scott@adrenaline.com"><scott@adrenaline.com></a> wrote:
</pre>
<blockquote type="cite">
<pre wrap="">To paraphrase Sarah Silverman's comedy special, "Vectors are Magic."
While cons cells can be allocated and initialized and chained together
one at a time, vector memory must be (or should be) allocated as a block
and then initialized in a nice tight loop. This creates some problems for
typed code.
Case in point, I'm trying to implement SML's style enumerate array
constructor in typed-scheme.
The code is a little messy as I've been trying different things,
but I think the essential errors are apparent.
(define: (x) (enumerate [size : Integer] [init : (Integer -> x)]) :
(Vectorof x)
(let: ([v : (Vectorof x) (make-vector size)]) ; <<< big problem
(for ([k (in-range size)]) <<< problem #2 I can't
seem to grok
(vector-set! v k (init k)))))
So the first obvious problem is that make-vector has no obvious
default value of the type variable x.
The second error is a little more obscure to me and relates to the for
expression.
Here is DrScheme's error message:
typecheck: untyped identifier in-range imported from module <for.ss> in:
in-range
typecheck: Expected (Vectorof x), but got Void in: fold-var
Scott
</pre>
</blockquote>
<pre wrap=""><!---->
</pre>
</blockquote>
<br>
</body>
</html>