将集合转换为表达式Maple/将前缀更改为固定表达式 [英] convert a set to expression Maple/ Change prefix to In-fix expression
问题描述
如何将以下设置转换为表达式
How to convert the below set to expression
Expression := {{a°b}, {a°x°y}} # ° can be any operator
要求的输出为
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);
但是我的输出是Pre-fix表达式的顺序.
but my output is in the order of Pre-fix expression.
结果:= {"°
(a,b),°
(°
(a,x),y)"}
result := {"°
(a,b), °
(°
(a,x),y)"}
亲切的问候
推荐答案
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.
这篇关于将集合转换为表达式Maple/将前缀更改为固定表达式的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!