4
$\begingroup$

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?

$\endgroup$
2

2 Answers 2

6
$\begingroup$

If you add the definition

CenterDot[u_] := u

then

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

factorizations

$\endgroup$
6
$\begingroup$

in 11.3 it works.

a = FactorInteger[Range[10, 11]]
b = Apply[Superscript, a, {2}]
f = If[Length@# == 1, #[[1]], CenterDot @@ #] &;
f /@ b
$\endgroup$
1
  • $\begingroup$ OK! Right! I got it! Thank you! $\endgroup$
    – user57467
    Commented Dec 14, 2019 at 4:13

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.