0

Hello and please forgive the beginners question. I am using Solve on a system of equations where results are presented in a format like the following (data is arbitrary in this example, however all numerical results are always a single digit integer):

{ {x -> 1, y -> 5, z -> 7}, {x -> 9, y -> 3, z -> 2}, {x -> 6, y -> 4, z -> 9} }

How can I refer to that output via % and have it reformatted as follows so that I may copy and paste it into a report?

[1,5,7] [9,3,2] [6,4,9]

This is not to be used in subsequent Mathematica calculations, but only used in an external report. As a start, I'm experimenting with StringRiffle and it is removing the braces and commas, but it is retaining the arrows, so I am missing something there.

Also, in a more complex reformatting of the output, how can I add additional text providing a reference number for each particular solution set such as:

1:[1,5,7] 2:[9,3,2] 3:[6,4,9]

Would it be helpful as an intermediate step in reformatting the output to assign the individual variables to members of an array? - so that a[1]=x, a[2]=y, and a[3]=z for example, or is that unnecessary? If that were done, then a loop index could generate the reference numbers to prepend to each member of the solution set.

Thanks in advance for all assistance!

Roger
  • 31
  • 2
  • I just answered your same question. Why did you delete it? You should delete this one and undelete the one which was answered which also had comment. If there is something you need to ask more, do it there. It is very rude to delete your question with answers. – Nasser Aug 08 '21 at 04:17
  • Apologies Nasser! I incorrectly posed the question originally with a poor title, making it appear that the unusually formatted output might be used in a subsequent calculation, versus just custom formatted text for use in an external report. I wanted to clarify that with a fresh start and a better title so as to not mislead others. I did study and save your answer, and it gave me greater understanding as I learn Mathematica, and I am very appreciative for your response and help. Thank you very much! – Roger Aug 08 '21 at 04:55
  • Sincere apologies again Nasser for the removal of your deeply appreciated answer when I reworked and reposted my question. Would you please be so kind as to post your answer again? I want the community to benefit from your effort and wisdom and I want to honor you. I don't know if your access to the post was removed when I deleted the post, so I have posted your response here https://tinyurl.com/2e9nd55h so that you may copy and paste. Thank you again, and I am sorry for the unintentional disrespect. It was certainly unintentional and you are very appreciated! – Roger Aug 08 '21 at 07:41

1 Answers1

1

You can use MapIndexed,Rowand Column, e.g.

q = {{x -> 1, y -> 5, z -> 7}, {x -> 9, y -> 3, z -> 2}, {x -> 6, 
 y -> 4, z -> 9}};
Column[MapIndexed[Row[{#2[[1]], ":[", x ,",", y, ",", z, "]"}] /. # &, 
q]]

enter image description here

ubpdqn
  • 60,617
  • 3
  • 59
  • 148