0

I want to input: Quaternion[1, 2, 3, 4] to get a list: {1,2,3,4}.

J. M.'s missing motivation
  • 124,525
  • 11
  • 401
  • 574
Geoffrey Critzer
  • 1,661
  • 1
  • 11
  • 14
  • 2
    You could always just List @@ q (see Apply). But then you can do almost anything with q = Quaternion[1,2,3,4] that you can do with {1,2,3,4}. For example, you can extract the 2nd part as q[[2]], etc. I am a bit tempted to vote to close as simple mistake. If you disagree, can you elaborate? – Szabolcs Feb 04 '16 at 10:49
  • @Szabolics Thank you. I was not aware that q[[2]] would extract the 2nd part. Now I am even more embarrassed to ask this question: I have: 7 + 5 Sqrt[2] but I want the list: {7,5}. – Geoffrey Critzer Feb 06 '16 at 13:36
  • 1
    This second question is not a simple one. The difficulty is deciding (i..e precisely defining) why the second term should be 5 and not 5 Sqrt[2] or something else. If we treat Sqrt[2] as special, we can use CoefficientList[7 + 5 Sqrt[2], Sqrt[2]]. – Szabolcs Feb 08 '16 at 10:35
  • Thank you very much Szabolics. I use CoefficientList quite often. I don't know why I did not think to try it here. – Geoffrey Critzer Feb 08 '16 at 10:52

0 Answers0