如何将下面的集合转换为表达式
Expression := {{a°b}, {a°x°y}} # ° can be any operator
所需输出为
result := {a°b, a°x°y} #required output
我尝试使用下面的转换函数进行转换,
asString := convert(Expression, string);
with(StringTools):
asString :=Remove("{}", asString)
result := InertForm:-Parse(asString);
但我的输出是按照前缀表达式的顺序。
结果:= {"°
(a,b), °
(°
(a,x),y)"}
亲切的问候
restart;
foo := {{a/b}, {a+x*y}}:
result := map(op, foo):
lprint(result);
{a/b, x*y+a}
无法保证结果集的条目的出现顺序与原始集的顺序相同。因此,使用集合来处理这种一般的事情永远不会正常工作。
这就是为什么我使用嵌套lists而不是嵌套sets,在我的回答中another https://stackoverflow.com/questions/52420940/extract-complete-expression-and-functions-name-from-the-standard-function-mapl上周关于这个主题的许多问题。您当前的问题表明您没有遵循我的建议。
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)