[Swift-user] question about SwiftScript
Mihael Hategan
hategan at mcs.anl.gov
Tue Sep 18 12:02:40 CDT 2007
On Tue, 2007-09-18 at 16:57 +0000, Ben Clifford wrote:
> I would expect you to have some problems there with some stuff that we
> haven't documented properly with regard to 'closing data sets'.
>
> Basically:
>
> > (file all[]) appl_n (int j)
> > {
> > if (j == 0) {
> > all[0] = gen0();
> > } else {
> > int k = j - 1;
> > all = appl_n (k);
> > all[j] = genn(all[k]);
> > }
> > }
>
> when appl_n returns, you can no longer assign anything more to all.
>
> So you might get problems here:
>
> > all = appl_n (k);
> > all[j] = genn(all[k]);
>
> because you've assign a value to all in the first line and are now no
> longer allowed to change it.
That, I believe, is easy to solve:
file[] tmp = appl_n(k);
foreach i in [0:k] {
all[i] = tmp[i];
}
all[j] = genn(all[k]);
Mihael
>
> I just added some docs this morning about something that might do
> something similar to what you are trying to do, which is the iterate
> language feature.
>
> Look at this chapter:
>
> http://www.ci.uchicago.edu/swift/guides/tutorial.php#tutorial.iterate
>
> on the 'sequential interation construct'.
>
> I think that corresponds roughly with what you are trying to do, but does
> it in an iterative style rather than a recursive style.
>
> (if you want to use this, grab the latest from SVN because I only just
> committed it and you'd be the first user of this...)
>
More information about the Swift-user
mailing list