Welcome to Cadabra Q&A, where you can ask questions and receive answers from other members of the community.
0 votes

I have asked in here, but I still don't know how to simplify following code

{\z1,\z2,...,\z100}::Weight(label=field, value=0);

I have tried

for i in range(101):
    Weight(Ex(r'\y'+str(i)),label=field, value=0)

and

for i in range(101):
    Ex(r'\y'+str(i)+r'::Weight(label=field, value=0)')

but they don't work. How to implement it?

asked in General questions by (770 points)
edited by

1 Answer

0 votes

Follow the example in a previous post


It was a simple application of the same philosophy:

for i in range(101):
    LaTeXForm(Ex(r'z'+str(i)+r'{#}'), Ex(r'"z_{'+str(i)+r'}"') )
    Weight(Ex(r'z'+str(i)+r'{#}'), Ex(r'label=field, value=1') )

ex := z1 z2 + z63;
keep_weight(ex, $field=2$);
answered by (6.3k points)
edited by

Thanks, doxdrum, I know this. I have written my above code through studying it. But I can't get the right result. There are some different points in my situation.

@Eureka: I updated my post. The solution was a simple application of the concepts from the previous post. Regards.

Thanks again, I get it. They're essentially the same thing. If there are more explanations about how to program in cadabra, the thing will be more simple. Maybe soon.

...