[Swift-user] Questions on use of iterate statement
Michael Wilde
wilde at mcs.anl.gov
Fri Feb 20 09:14:34 CST 2009
OK. I was cinsidering that, but I'll need to use a 2-d array as the
simulation itself generates a vector of results.
I'll try this.
Thanks,
Mike
On 2/20/09 7:45 AM, Ben Clifford wrote:
> In many (all?) cases you should be able to declare an array outside of the
> iteration, with each element of the array holding the result of each step,
> like this:
>
> int j[];
> iterate i {
> j[i] = i * i;
> trace(j[i]);
> } until (j[i]>15);
>
> That was the main way in which I invisioned iterate being used when I
> implemented it, i think, so that you would map steps of your iteration
> using a single mapper declaration on j[] rather than inside the iteration
> body. That comes from imagining it as something like a functional 'unfold'
> expression (eg
> http://www.haskell.org/ghc/docs/latest/html/libraries/base/Data-List.html#9)
> where entire structures such as lists are constructed as a single
> expression.
>
> It seems reasonable that body variables be made available to the
> termination expression, though, to support the style that you attempted,
> so I'll put that in the bugzilla as a language feature request.
>
More information about the Swift-user
mailing list