[Swift-user] question about SwiftScript

Mihael Hategan hategan at mcs.anl.gov
Tue Sep 18 11:57:29 CDT 2007


On Tue, 2007-09-18 at 11:45 -0500, Jim Kowalkowski wrote:
> Hello,
> 
> I have a question about SwiftScript.  Should I expect the following to work?

Nope, as far as I can tell.

> If not, why should I not expect it to work?

No recursion support in Swift. Which is somewhat silly.
But Ben has been working on a way to do that kind of folding operation.
Maybe he can provide some details.

> 
> Please assume that the app works - I've tested this part on a simpler 
> script.
> At the bottom is the test functions that actually work.
> 
> Thanks in advance,
> Jim Kowalkowski
> Fermilab CD
> --------------------
> type file { };
> 
> (file o) gen0() {
>   app {
>     echo2 @filename(o);
>   }
> }
> 
> (file o) genn(file i)
> {
>   app {
>     echo @filename(i) @filename(o);
>   }   
> }
> 
> (file o) appl_0 ()
> {
>   o = gen0();
> }
> (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]);
>   }
> }
> 
> string filenames = "0.txt 1.txt 2.txt 3.txt 4.txt 5.txt";
> file ifiles[] <fixed_array_mapper;files=filenames>;
> 
> ifiles = appl_n(5);
> 
> #------ if I run the function below, it works fine -------
> 
> (file inputfiles[]) simple_run ()
> {
>  inputfiles[5] = genn (inputfiles[4]);
>  inputfiles[4] = genn (inputfiles[3]);
>  inputfiles[3] = genn (inputfiles[2]);
>  inputfiles[2] = genn (inputfiles[1]);
>  inputfiles[1] = genn (inputfiles[0]);
>  inputfiles[0] = gen0 ();
> }
> 
> files more[] = <fixed_array_mapper; files=filenames>;
> more = simple_run();
> 
> #-------- I ran also run this and it works ----------
> 
> run_dep (file fs[], int curr)
> {
>   int prev = curr - 1;
>   fs[curr] = genn( fs[prev] );
> }
> 
> (file inputfiles[]) other_run ()
> {
>  inputfiles = run_dep(5);
>  inputfiles = run_dep(4);
>  inputfiles = run_dep(3);
>  inputfiles = run_dep(2);
>  inputfiles = run_dep(1);
>  inputfiles[0] = gen0();
> }
> 
> more = other_run();
> 
> 
> _______________________________________________
> Swift-user mailing list
> Swift-user at ci.uchicago.edu
> http://mail.ci.uchicago.edu/mailman/listinfo/swift-user
> 




More information about the Swift-user mailing list