On Tue, 3 Jul 2018, Sven Schreiber wrote:
Am 03.07.2018 um 12:37 schrieb Riccardo (Jack) Lucchetti:
> On Tue, 3 Jul 2018, Sven Schreiber wrote:
>
>> Hi,
>>
>> I've noticed that in a lot of hansl code many lines are spent on copying
>> stuff into bundles, and I wonder if that could be made easier. What I have
>> in mind is something like the function below, which would be called for
>> example like this:
>>
>> copy2bundle(b, defbundle("m", mymatrix, "s", mystring,
"m2",
>> anothermatrix))
>>
>> However, perhaps a built-in gretl function would be better and less
>> clumsy. For example, the input wouldn't have to be wrapped in a transitory
>> bundle and still the number of arguments to copy would be flexible.
>
> We have '+'; for example:
> <hansl>
> bundle a
> a.uno = 1
> a = a + defbundle("due", 2)
> print a
> </hansl>
Yeah, this is what I used in my example function as well. However, when you
also want to update elements in the bundle, this doesn't work.
In that case reverse the operands:
<hansl>
bundle a
a.uno = 1
a.due = 2
# add one element, revise another
a = defbundle("tre", 3, "due", "$10") + a
print a
</hansl>
Allin