convert a set to expression Maple/ Change prefix to In-fix expression

一个人想着一个人 提交于 2019-12-12 20:07:23

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!