问题
How to convert the below set to expression
Expression := {{a°b}, {a°x°y}} # ° can be any operator
required output as
result := {a°b, a°x°y} #required output
I have tried to convert using convert function like below,
asString := convert(Expression, string);
with(StringTools):
asString :=Remove("{}", asString)
result := InertForm:-Parse(asString);
but my output is in the order of Pre-fix expression.
result := {"°
(a,b), °
(°
(a,x),y)"}
Kind regards
回答1:
restart;
foo := {{a/b}, {a+x*y}}:
result := map(op, foo):
lprint(result);
{a/b, x*y+a}
There is no guarantee that the resulting set will have its entries appearing in the same order as the original set of sets. And hence using sets for this general kind of thing is never going to work properly.
That's why I used nested lists instead of nested sets, in my answers to another of your many questions on this theme last week. Your current Question indicates that you're not following my advice.
来源:https://stackoverflow.com/questions/52519052/convert-a-set-to-expression-maple-change-prefix-to-in-fix-expression