4

How can I get the canonical form of a list? I tried

a = FactorInteger[Range[10, 11]]
b = Apply[Superscript, a, {2}]
CenterDot @@@ b

resulting in

{Superscript[2,1]\[CenterDot]Superscript[5,1], 
 CenterDot[Superscript[11,1]]}

Output for 10 is OK. But for case 11 the word "CenterDot" is in the output. How do I get rid of it? Or is there a more elegant way to "canonize" list or lists of integers?

user57467
  • 2,708
  • 6
  • 12

2 Answers2

6

in 11.3 it works.

a = FactorInteger[Range[10, 11]]
b = Apply[Superscript, a, {2}]
f = If[Length@# == 1, #[[1]], CenterDot @@ #] &;
f /@ b
AsukaMinato
  • 9,758
  • 1
  • 14
  • 40
6

If you add the definition

CenterDot[u_] := u

then

a = FactorInteger[Range[1, 11]];
b = Apply[Superscript, a, {-2}];
CenterDot @@@ b

factorizations

m_goldberg
  • 107,779
  • 16
  • 103
  • 257