How to avoid applying Cross to a single argument?
Clash Royale CLAN TAG#URR8PPP
up vote
4
down vote
favorite
I am looking for the simplest way to avoid applying Cross
to a single argument.
PrimeFactorization[x_] := Cross @@ (Superscript @@@ FactorInteger[x]);
Table[n, PrimeFactorization[n], n, 200, 250] // TableForm
conditional
add a comment |Â
up vote
4
down vote
favorite
I am looking for the simplest way to avoid applying Cross
to a single argument.
PrimeFactorization[x_] := Cross @@ (Superscript @@@ FactorInteger[x]);
Table[n, PrimeFactorization[n], n, 200, 250] // TableForm
conditional
What aboutIf
?
– Kuba♦
Aug 16 at 8:00
Down vote detected. Thank you!
– Friendly Ghost
Aug 17 at 12:55
add a comment |Â
up vote
4
down vote
favorite
up vote
4
down vote
favorite
I am looking for the simplest way to avoid applying Cross
to a single argument.
PrimeFactorization[x_] := Cross @@ (Superscript @@@ FactorInteger[x]);
Table[n, PrimeFactorization[n], n, 200, 250] // TableForm
conditional
I am looking for the simplest way to avoid applying Cross
to a single argument.
PrimeFactorization[x_] := Cross @@ (Superscript @@@ FactorInteger[x]);
Table[n, PrimeFactorization[n], n, 200, 250] // TableForm
conditional
edited Aug 16 at 8:00
asked Aug 16 at 7:52


Friendly Ghost
2076
2076
What aboutIf
?
– Kuba♦
Aug 16 at 8:00
Down vote detected. Thank you!
– Friendly Ghost
Aug 17 at 12:55
add a comment |Â
What aboutIf
?
– Kuba♦
Aug 16 at 8:00
Down vote detected. Thank you!
– Friendly Ghost
Aug 17 at 12:55
What about
If
?– Kuba♦
Aug 16 at 8:00
What about
If
?– Kuba♦
Aug 16 at 8:00
Down vote detected. Thank you!
– Friendly Ghost
Aug 17 at 12:55
Down vote detected. Thank you!
– Friendly Ghost
Aug 17 at 12:55
add a comment |Â
6 Answers
6
active
oldest
votes
up vote
8
down vote
accepted
Since you already use Cross
in a way that it's not meant to be used, you can also redefine it and assign a meaning to it when it has only a single argument:
Unprotect[Cross];
Cross[x_] := x;
A bit less severe: Define your own function.
cross[x__] := Cross[x];
cross[x_] := x;
add a comment |Â
up vote
11
down vote
If it is only for displaying purposes you can use Row
:
PrimeFactorization[x_] := Row[#, "[Cross]"] & @ (Superscript @@@ FactorInteger[x])
This solution is not TeXForm friendly. Thank you!
– Friendly Ghost
Aug 16 at 8:10
9
@FriendlyGhost there is nothing about TeXForm in your question.
– Kuba♦
Aug 16 at 8:12
@FriendlyGhost, useBoxForm`$UseTemplateSlotSequenceForRow = False;
before usingTeXForm
on expressions involvingRow
.(See Incompatibility of Row and TeXForm)
– kglr
Aug 17 at 8:12
add a comment |Â
up vote
6
down vote
You might define your own function cross, that calls Cross when the number of arguments is larger than 1:
cross=If[Length[##]>1, Cross[##], #]&;
Thanks. Is there any method to check the number of arguments instead of using your trick withLength[...]
?
– Friendly Ghost
Aug 16 at 8:03
add a comment |Â
up vote
5
down vote
An alternative solution without defining new functions:
PrimeFactorization[x_] :=
Superscript @@@ FactorInteger[x] /. y_ /; Length@y < 0 -> Cross @@ y
add a comment |Â
up vote
5
down vote
For displaying purposes you can also use:
Times @@ Defer@*Power @@@ FactorInteger[10!]
CenterDot @@ Superscript @@@ FactorInteger[10!]
Inactive[Times] @@ Superscript @@@ FactorInteger[10!]
(+1) This does not resolve the issue with numbers that are a power if a prime though.
– Henrik Schumacher
Aug 16 at 16:59
add a comment |Â
up vote
2
down vote
You can use Block
in two ways:
- temporarily re-define
Cross
so thatCross[t_] := t
:
PrimeFactorization[x_] := Block[Cross, Cross[t_] := t;
Cross @@ Superscript @@@ FactorInteger @ x];
PrimeFactorization /@ 211, 222, 223 // TeXForm
$left211^1,2^1times 3^1times 37^1,223^1right$
- temporarily define
Sequence
asCross
:
PrimeFactorization2[x_] := Block[Sequence = Cross,
## & @@ Superscript @@@ FactorInteger @ x];
PrimeFactorization2 /@ 211, 222, 223 // TeXForm
$left211^1,2^1times 3^1times 37^1,223^1right$
I already up voted this answer! The proof (click).
– Friendly Ghost
Aug 17 at 13:23
add a comment |Â
6 Answers
6
active
oldest
votes
6 Answers
6
active
oldest
votes
active
oldest
votes
active
oldest
votes
up vote
8
down vote
accepted
Since you already use Cross
in a way that it's not meant to be used, you can also redefine it and assign a meaning to it when it has only a single argument:
Unprotect[Cross];
Cross[x_] := x;
A bit less severe: Define your own function.
cross[x__] := Cross[x];
cross[x_] := x;
add a comment |Â
up vote
8
down vote
accepted
Since you already use Cross
in a way that it's not meant to be used, you can also redefine it and assign a meaning to it when it has only a single argument:
Unprotect[Cross];
Cross[x_] := x;
A bit less severe: Define your own function.
cross[x__] := Cross[x];
cross[x_] := x;
add a comment |Â
up vote
8
down vote
accepted
up vote
8
down vote
accepted
Since you already use Cross
in a way that it's not meant to be used, you can also redefine it and assign a meaning to it when it has only a single argument:
Unprotect[Cross];
Cross[x_] := x;
A bit less severe: Define your own function.
cross[x__] := Cross[x];
cross[x_] := x;
Since you already use Cross
in a way that it's not meant to be used, you can also redefine it and assign a meaning to it when it has only a single argument:
Unprotect[Cross];
Cross[x_] := x;
A bit less severe: Define your own function.
cross[x__] := Cross[x];
cross[x_] := x;
edited Aug 16 at 8:07
answered Aug 16 at 8:02


Henrik Schumacher
36k249102
36k249102
add a comment |Â
add a comment |Â
up vote
11
down vote
If it is only for displaying purposes you can use Row
:
PrimeFactorization[x_] := Row[#, "[Cross]"] & @ (Superscript @@@ FactorInteger[x])
This solution is not TeXForm friendly. Thank you!
– Friendly Ghost
Aug 16 at 8:10
9
@FriendlyGhost there is nothing about TeXForm in your question.
– Kuba♦
Aug 16 at 8:12
@FriendlyGhost, useBoxForm`$UseTemplateSlotSequenceForRow = False;
before usingTeXForm
on expressions involvingRow
.(See Incompatibility of Row and TeXForm)
– kglr
Aug 17 at 8:12
add a comment |Â
up vote
11
down vote
If it is only for displaying purposes you can use Row
:
PrimeFactorization[x_] := Row[#, "[Cross]"] & @ (Superscript @@@ FactorInteger[x])
This solution is not TeXForm friendly. Thank you!
– Friendly Ghost
Aug 16 at 8:10
9
@FriendlyGhost there is nothing about TeXForm in your question.
– Kuba♦
Aug 16 at 8:12
@FriendlyGhost, useBoxForm`$UseTemplateSlotSequenceForRow = False;
before usingTeXForm
on expressions involvingRow
.(See Incompatibility of Row and TeXForm)
– kglr
Aug 17 at 8:12
add a comment |Â
up vote
11
down vote
up vote
11
down vote
If it is only for displaying purposes you can use Row
:
PrimeFactorization[x_] := Row[#, "[Cross]"] & @ (Superscript @@@ FactorInteger[x])
If it is only for displaying purposes you can use Row
:
PrimeFactorization[x_] := Row[#, "[Cross]"] & @ (Superscript @@@ FactorInteger[x])
answered Aug 16 at 8:04


Kuba♦
99.3k11194491
99.3k11194491
This solution is not TeXForm friendly. Thank you!
– Friendly Ghost
Aug 16 at 8:10
9
@FriendlyGhost there is nothing about TeXForm in your question.
– Kuba♦
Aug 16 at 8:12
@FriendlyGhost, useBoxForm`$UseTemplateSlotSequenceForRow = False;
before usingTeXForm
on expressions involvingRow
.(See Incompatibility of Row and TeXForm)
– kglr
Aug 17 at 8:12
add a comment |Â
This solution is not TeXForm friendly. Thank you!
– Friendly Ghost
Aug 16 at 8:10
9
@FriendlyGhost there is nothing about TeXForm in your question.
– Kuba♦
Aug 16 at 8:12
@FriendlyGhost, useBoxForm`$UseTemplateSlotSequenceForRow = False;
before usingTeXForm
on expressions involvingRow
.(See Incompatibility of Row and TeXForm)
– kglr
Aug 17 at 8:12
This solution is not TeXForm friendly. Thank you!
– Friendly Ghost
Aug 16 at 8:10
This solution is not TeXForm friendly. Thank you!
– Friendly Ghost
Aug 16 at 8:10
9
9
@FriendlyGhost there is nothing about TeXForm in your question.
– Kuba♦
Aug 16 at 8:12
@FriendlyGhost there is nothing about TeXForm in your question.
– Kuba♦
Aug 16 at 8:12
@FriendlyGhost, use
BoxForm`$UseTemplateSlotSequenceForRow = False;
before using TeXForm
on expressions involving Row
.(See Incompatibility of Row and TeXForm)– kglr
Aug 17 at 8:12
@FriendlyGhost, use
BoxForm`$UseTemplateSlotSequenceForRow = False;
before using TeXForm
on expressions involving Row
.(See Incompatibility of Row and TeXForm)– kglr
Aug 17 at 8:12
add a comment |Â
up vote
6
down vote
You might define your own function cross, that calls Cross when the number of arguments is larger than 1:
cross=If[Length[##]>1, Cross[##], #]&;
Thanks. Is there any method to check the number of arguments instead of using your trick withLength[...]
?
– Friendly Ghost
Aug 16 at 8:03
add a comment |Â
up vote
6
down vote
You might define your own function cross, that calls Cross when the number of arguments is larger than 1:
cross=If[Length[##]>1, Cross[##], #]&;
Thanks. Is there any method to check the number of arguments instead of using your trick withLength[...]
?
– Friendly Ghost
Aug 16 at 8:03
add a comment |Â
up vote
6
down vote
up vote
6
down vote
You might define your own function cross, that calls Cross when the number of arguments is larger than 1:
cross=If[Length[##]>1, Cross[##], #]&;
You might define your own function cross, that calls Cross when the number of arguments is larger than 1:
cross=If[Length[##]>1, Cross[##], #]&;
edited Aug 17 at 6:51
answered Aug 16 at 8:01
Fred Simons
6,9601141
6,9601141
Thanks. Is there any method to check the number of arguments instead of using your trick withLength[...]
?
– Friendly Ghost
Aug 16 at 8:03
add a comment |Â
Thanks. Is there any method to check the number of arguments instead of using your trick withLength[...]
?
– Friendly Ghost
Aug 16 at 8:03
Thanks. Is there any method to check the number of arguments instead of using your trick with
Length[...]
?– Friendly Ghost
Aug 16 at 8:03
Thanks. Is there any method to check the number of arguments instead of using your trick with
Length[...]
?– Friendly Ghost
Aug 16 at 8:03
add a comment |Â
up vote
5
down vote
An alternative solution without defining new functions:
PrimeFactorization[x_] :=
Superscript @@@ FactorInteger[x] /. y_ /; Length@y < 0 -> Cross @@ y
add a comment |Â
up vote
5
down vote
An alternative solution without defining new functions:
PrimeFactorization[x_] :=
Superscript @@@ FactorInteger[x] /. y_ /; Length@y < 0 -> Cross @@ y
add a comment |Â
up vote
5
down vote
up vote
5
down vote
An alternative solution without defining new functions:
PrimeFactorization[x_] :=
Superscript @@@ FactorInteger[x] /. y_ /; Length@y < 0 -> Cross @@ y
An alternative solution without defining new functions:
PrimeFactorization[x_] :=
Superscript @@@ FactorInteger[x] /. y_ /; Length@y < 0 -> Cross @@ y
answered Aug 16 at 8:03
Fraccalo
2,184517
2,184517
add a comment |Â
add a comment |Â
up vote
5
down vote
For displaying purposes you can also use:
Times @@ Defer@*Power @@@ FactorInteger[10!]
CenterDot @@ Superscript @@@ FactorInteger[10!]
Inactive[Times] @@ Superscript @@@ FactorInteger[10!]
(+1) This does not resolve the issue with numbers that are a power if a prime though.
– Henrik Schumacher
Aug 16 at 16:59
add a comment |Â
up vote
5
down vote
For displaying purposes you can also use:
Times @@ Defer@*Power @@@ FactorInteger[10!]
CenterDot @@ Superscript @@@ FactorInteger[10!]
Inactive[Times] @@ Superscript @@@ FactorInteger[10!]
(+1) This does not resolve the issue with numbers that are a power if a prime though.
– Henrik Schumacher
Aug 16 at 16:59
add a comment |Â
up vote
5
down vote
up vote
5
down vote
For displaying purposes you can also use:
Times @@ Defer@*Power @@@ FactorInteger[10!]
CenterDot @@ Superscript @@@ FactorInteger[10!]
Inactive[Times] @@ Superscript @@@ FactorInteger[10!]
For displaying purposes you can also use:
Times @@ Defer@*Power @@@ FactorInteger[10!]
CenterDot @@ Superscript @@@ FactorInteger[10!]
Inactive[Times] @@ Superscript @@@ FactorInteger[10!]
answered Aug 16 at 11:38
chyanog
6,74921544
6,74921544
(+1) This does not resolve the issue with numbers that are a power if a prime though.
– Henrik Schumacher
Aug 16 at 16:59
add a comment |Â
(+1) This does not resolve the issue with numbers that are a power if a prime though.
– Henrik Schumacher
Aug 16 at 16:59
(+1) This does not resolve the issue with numbers that are a power if a prime though.
– Henrik Schumacher
Aug 16 at 16:59
(+1) This does not resolve the issue with numbers that are a power if a prime though.
– Henrik Schumacher
Aug 16 at 16:59
add a comment |Â
up vote
2
down vote
You can use Block
in two ways:
- temporarily re-define
Cross
so thatCross[t_] := t
:
PrimeFactorization[x_] := Block[Cross, Cross[t_] := t;
Cross @@ Superscript @@@ FactorInteger @ x];
PrimeFactorization /@ 211, 222, 223 // TeXForm
$left211^1,2^1times 3^1times 37^1,223^1right$
- temporarily define
Sequence
asCross
:
PrimeFactorization2[x_] := Block[Sequence = Cross,
## & @@ Superscript @@@ FactorInteger @ x];
PrimeFactorization2 /@ 211, 222, 223 // TeXForm
$left211^1,2^1times 3^1times 37^1,223^1right$
I already up voted this answer! The proof (click).
– Friendly Ghost
Aug 17 at 13:23
add a comment |Â
up vote
2
down vote
You can use Block
in two ways:
- temporarily re-define
Cross
so thatCross[t_] := t
:
PrimeFactorization[x_] := Block[Cross, Cross[t_] := t;
Cross @@ Superscript @@@ FactorInteger @ x];
PrimeFactorization /@ 211, 222, 223 // TeXForm
$left211^1,2^1times 3^1times 37^1,223^1right$
- temporarily define
Sequence
asCross
:
PrimeFactorization2[x_] := Block[Sequence = Cross,
## & @@ Superscript @@@ FactorInteger @ x];
PrimeFactorization2 /@ 211, 222, 223 // TeXForm
$left211^1,2^1times 3^1times 37^1,223^1right$
I already up voted this answer! The proof (click).
– Friendly Ghost
Aug 17 at 13:23
add a comment |Â
up vote
2
down vote
up vote
2
down vote
You can use Block
in two ways:
- temporarily re-define
Cross
so thatCross[t_] := t
:
PrimeFactorization[x_] := Block[Cross, Cross[t_] := t;
Cross @@ Superscript @@@ FactorInteger @ x];
PrimeFactorization /@ 211, 222, 223 // TeXForm
$left211^1,2^1times 3^1times 37^1,223^1right$
- temporarily define
Sequence
asCross
:
PrimeFactorization2[x_] := Block[Sequence = Cross,
## & @@ Superscript @@@ FactorInteger @ x];
PrimeFactorization2 /@ 211, 222, 223 // TeXForm
$left211^1,2^1times 3^1times 37^1,223^1right$
You can use Block
in two ways:
- temporarily re-define
Cross
so thatCross[t_] := t
:
PrimeFactorization[x_] := Block[Cross, Cross[t_] := t;
Cross @@ Superscript @@@ FactorInteger @ x];
PrimeFactorization /@ 211, 222, 223 // TeXForm
$left211^1,2^1times 3^1times 37^1,223^1right$
- temporarily define
Sequence
asCross
:
PrimeFactorization2[x_] := Block[Sequence = Cross,
## & @@ Superscript @@@ FactorInteger @ x];
PrimeFactorization2 /@ 211, 222, 223 // TeXForm
$left211^1,2^1times 3^1times 37^1,223^1right$
edited Aug 17 at 7:46
answered Aug 17 at 7:24
kglr
158k8182380
158k8182380
I already up voted this answer! The proof (click).
– Friendly Ghost
Aug 17 at 13:23
add a comment |Â
I already up voted this answer! The proof (click).
– Friendly Ghost
Aug 17 at 13:23
I already up voted this answer! The proof (click).
– Friendly Ghost
Aug 17 at 13:23
I already up voted this answer! The proof (click).
– Friendly Ghost
Aug 17 at 13:23
add a comment |Â
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fmathematica.stackexchange.com%2fquestions%2f180098%2fhow-to-avoid-applying-cross-to-a-single-argument%23new-answer', 'question_page');
);
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
What about
If
?– Kuba♦
Aug 16 at 8:00
Down vote detected. Thank you!
– Friendly Ghost
Aug 17 at 12:55