2

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

Kumar
  • 87
  • 5
Rohithsai Sai
  • 468
  • 4
  • 17

1 Answers1

0
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.

acer
  • 6,671
  • 15
  • 15