[Swift-devel] loops and strings
Ian Foster
itf at mcs.anl.gov
Fri Jul 27 13:32:16 CDT 2007
Can you propose a general solution?
Sent via BlackBerry from T-Mobile
-----Original Message-----
From: Mihael Hategan <hategan at mcs.anl.gov>
Date: Fri, 27 Jul 2007 13:24:34
To:Veronika Nefedova <nefedova at mcs.anl.gov>
Cc:swift-devel at ci.uchicago.edu
Subject: Re: [Swift-devel] loops and strings
I see we're getting back to the same old story of the conflict between
writing a mapper and hacking one directly in swift.
This is an issue we really need to deal with. It has produced more
discussions and hacks than any other single Swift issue.
You could use an array, or we could provide a folding operator/function,
or even a join function.
We could also let fixed_array_mapper accept an array as a parameter, so
you would build an array with the file names and then pass it to the
mapper.
On Fri, 2007-07-27 at 11:09 -0500, Veronika Nefedova wrote:
> I need to 'cat' together an unknown number of strings to form a
> string, thats why I was attempting to do it inside the loop. And even
> if I knew the number of loop cycles (say, its 68) -- are you
> suggesting to do it 'by hand' ?
>
>
> Anyway - my main goal is not to create this string, but to map an array:
> file whamfiles_$s[] <fixed_array_mapper;files="$wham_string">;
>
> Do you see a solution here?
>
> Thanks,
>
> Nika
>
>
> On Jul 27, 2007, at 11:01 AM, Mihael Hategan wrote:
>
> > wham_string2 = @strcat(wham_string, ", wham");
> > print(wham_string2);
> >
> > Variables are not variables. They are labels that are used to
> > direct the
> > data flow. Loops (in the sense of data looping around the same node -
> > picture this as a data flow graph) make no sense.
> >
> > On Fri, 2007-07-27 at 10:50 -0500, Veronika Nefedova wrote:
> >> So how else then I construct a string in swift ?
> >>
> >>
> >> On Jul 27, 2007, at 10:46 AM, Mihael Hategan wrote:
> >>
> >>> Variables in swift are single assignment. You can't assign to a
> >>> variable
> >>> twice. What, in your opinion, should the error message be instead
> >>> of the
> >>> current one?
> >>>
> >>> On Fri, 2007-07-27 at 10:22 -0500, Veronika Nefedova wrote:
> >>>> I am not sure if its possible to do string operations inside the
> >>>> loop
> >>>> in swift?
> >>>> I have a versy simple test code that doesn't work no matter what.
> >>>> Obviously, I am missing something.
> >>>> This is the code:
> >>>>
> >>>> file fls[]<filesys_mapper;pattern="*.prt",location=".">;
> >>>> string wham_string = "#";
> >>>> foreach prt_file in fls
> >>>> {
> >>>> wham_string = @strcat (wham_string, ", wham");
> >>>> print (wham_string);
> >>>> }
> >>>> print (wham_string);
> >>>>
> >>>>
> >>>> basically I expect to have this as an output:
> >>>> #,wham,wham,wham,wham,... (its a test code (-;)
> >>>>
> >>>> instead I have these errors:
> >>>>
> >>>> wham_string is already assigned with a value of #
> >>>> wham_string is already assigned with a value of #
> >>>> vdl:assign @ test.kml, line: 46
> >>>> vdl:mains @ test.kml, line: 39
> >>>> Caused by: java.lang.IllegalArgumentException: wham_string is
> >>>> already
> >>>> assigned with a value of #
> >>>> at org.griphyn.vdl.mapping.AbstractDataNode.setValue
> >>>> (AbstractDataNode.java:255)
> >>>> at org.griphyn.vdl.karajan.lib.Assign.function
> >>>> (Assign.java:70)
> >>>> <snip>
> >>>>
> >>>>
> >>>> In any case -- if I can't construct the string by using the loop -
> >>>> how else could it be done?
> >>>>
> >>>> I use the constructed string then to map an array (I understand I
> >>>> can't map individual array elements):
> >>>>
> >>>> file whamfiles_$s[] <fixed_array_mapper;files="$wham_string">; //it
> >>>> was in the wrapper script before)
> >>>>
> >>>>
> >>>> Nika
> >>>>
> >>>> _______________________________________________
> >>>> Swift-devel mailing list
> >>>> Swift-devel at ci.uchicago.edu
> >>>> http://mail.ci.uchicago.edu/mailman/listinfo/swift-devel
> >>>>
> >>>
> >>
> >
>
_______________________________________________
Swift-devel mailing list
Swift-devel at ci.uchicago.edu
http://mail.ci.uchicago.edu/mailman/listinfo/swift-devel
More information about the Swift-devel
mailing list