[Swift-devel] loops and strings
Veronika Nefedova
nefedova at mcs.anl.gov
Fri Jul 27 15:13:20 CDT 2007
ok, here is the problem I do not see how to bypass.
I have an outer loop:
foreach f in files {
string S = "bla"
}
I need to have this array declared, and if I generate the string in
the shell script, it has to be declared explicitly:
foreach f in files {
string S = "bla"
file whamfiles [] <fixed_array_mapper;files="file1_S, file2_S,
file3_S">;
}
and it has to be "S", not its value since its all inside the loop.
But for swift to recognize S as its own variable (and substitute its
value on every loop step) I need to use strcat:
@strcat("file1_", S), @strcat("file2_", S), etc for each of the
string's element -- I do not see a way for doing it so far without
being able to construct a string in swift... There are 68 elements in
that string but could be any number.
Does anybody have any suggestions?
Nika
> This proves a bit cumbersome to have this combination of swift and
> the wrapper. This array declaration has to be inside another loop,
> i.e. depend on the loop variable, yet being generated by shell
> script... I am still testing various possibilities. Although
> generating the string inside swift would've been much easier.
>
> On Jul 27, 2007, at 2:20 PM, Ian Foster wrote:
>
>> Could you not handle the "cat a set of strings" case via a call to
>> a shell script or other program that does this?
>>
>> Ian
>>
>>
>> Sent via BlackBerry from T-Mobile
>>
>> -----Original Message-----
>> From: Veronika Nefedova <nefedova at mcs.anl.gov>
>>
>> Date: Fri, 27 Jul 2007 11:09:19
>> To:Mihael Hategan <hategan at mcs.anl.gov>
>> Cc:swift-devel at ci.uchicago.edu
>> Subject: Re: [Swift-devel] loops and strings
>>
>>
>> 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
>>
>
> _______________________________________________
> 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