3
$\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$
5
$\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$
  • $\begingroup$ OK! Right! I got it! Thank you! $\endgroup$ – user57467 Dec 14 '19 at 4:13
5
$\begingroup$

If you add the definition

CenterDot[u_] := u

then

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

factorizations

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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