How to avoid applying Cross to a single argument?

The name of the pictureThe name of the pictureThe name of the pictureClash 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


enter image description here







share|improve this question






















  • What about If?
    – Kuba♦
    Aug 16 at 8:00










  • Down vote detected. Thank you!
    – Friendly Ghost
    Aug 17 at 12:55














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


enter image description here







share|improve this question






















  • What about If?
    – Kuba♦
    Aug 16 at 8:00










  • Down vote detected. Thank you!
    – Friendly Ghost
    Aug 17 at 12:55












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


enter image description here







share|improve this question














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


enter image description here









share|improve this question













share|improve this question




share|improve this question








edited Aug 16 at 8:00

























asked Aug 16 at 7:52









Friendly Ghost

2076




2076











  • What about If?
    – 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










  • 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










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;





share|improve this answer





























    up vote
    11
    down vote













    If it is only for displaying purposes you can use Row:



    PrimeFactorization[x_] := Row[#, "[Cross]"] & @ (Superscript @@@ FactorInteger[x])





    share|improve this answer




















    • 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, use BoxForm`$UseTemplateSlotSequenceForRow = False; before using TeXForm on expressions involving Row.(See Incompatibility of Row and TeXForm)
      – kglr
      Aug 17 at 8:12


















    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[##], #]&;





    share|improve this answer






















    • 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

















    up vote
    5
    down vote













    An alternative solution without defining new functions:



    PrimeFactorization[x_] :=

    Superscript @@@ FactorInteger[x] /. y_ /; Length@y < 0 -> Cross @@ y





    share|improve this answer



























      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!]


      enter image description here






      share|improve this answer




















      • (+1) This does not resolve the issue with numbers that are a power if a prime though.
        – Henrik Schumacher
        Aug 16 at 16:59

















      up vote
      2
      down vote













      You can use Block in two ways:



      1. temporarily re-define Cross so that Cross[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$




      1. temporarily define Sequence as Cross:



      PrimeFactorization2[x_] := Block[Sequence = Cross,
      ## & @@ Superscript @@@ FactorInteger @ x];

      PrimeFactorization2 /@ 211, 222, 223 // TeXForm



      $left211^1,2^1times 3^1times 37^1,223^1right$







      share|improve this answer






















      • I already up voted this answer! The proof (click).
        – Friendly Ghost
        Aug 17 at 13:23











      Your Answer




      StackExchange.ifUsing("editor", function ()
      return StackExchange.using("mathjaxEditing", function ()
      StackExchange.MarkdownEditor.creationCallbacks.add(function (editor, postfix)
      StackExchange.mathjaxEditing.prepareWmdForMathJax(editor, postfix, [["$", "$"], ["\\(","\\)"]]);
      );
      );
      , "mathjax-editing");

      StackExchange.ready(function()
      var channelOptions =
      tags: "".split(" "),
      id: "387"
      ;
      initTagRenderer("".split(" "), "".split(" "), channelOptions);

      StackExchange.using("externalEditor", function()
      // Have to fire editor after snippets, if snippets enabled
      if (StackExchange.settings.snippets.snippetsEnabled)
      StackExchange.using("snippets", function()
      createEditor();
      );

      else
      createEditor();

      );

      function createEditor()
      StackExchange.prepareEditor(
      heartbeatType: 'answer',
      convertImagesToLinks: false,
      noModals: false,
      showLowRepImageUploadWarning: true,
      reputationToPostImages: null,
      bindNavPrevention: true,
      postfix: "",
      onDemand: true,
      discardSelector: ".discard-answer"
      ,immediatelyShowMarkdownHelp:true
      );



      );













       

      draft saved


      draft discarded


















      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






























      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;





      share|improve this answer


























        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;





        share|improve this answer
























          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;





          share|improve this answer














          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;






          share|improve this answer














          share|improve this answer



          share|improve this answer








          edited Aug 16 at 8:07

























          answered Aug 16 at 8:02









          Henrik Schumacher

          36k249102




          36k249102




















              up vote
              11
              down vote













              If it is only for displaying purposes you can use Row:



              PrimeFactorization[x_] := Row[#, "[Cross]"] & @ (Superscript @@@ FactorInteger[x])





              share|improve this answer




















              • 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, use BoxForm`$UseTemplateSlotSequenceForRow = False; before using TeXForm on expressions involving Row.(See Incompatibility of Row and TeXForm)
                – kglr
                Aug 17 at 8:12















              up vote
              11
              down vote













              If it is only for displaying purposes you can use Row:



              PrimeFactorization[x_] := Row[#, "[Cross]"] & @ (Superscript @@@ FactorInteger[x])





              share|improve this answer




















              • 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, use BoxForm`$UseTemplateSlotSequenceForRow = False; before using TeXForm on expressions involving Row.(See Incompatibility of Row and TeXForm)
                – kglr
                Aug 17 at 8:12













              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])





              share|improve this answer












              If it is only for displaying purposes you can use Row:



              PrimeFactorization[x_] := Row[#, "[Cross]"] & @ (Superscript @@@ FactorInteger[x])






              share|improve this answer












              share|improve this answer



              share|improve this answer










              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, use BoxForm`$UseTemplateSlotSequenceForRow = False; before using TeXForm on expressions involving Row.(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






              • 9




                @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
















              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











              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[##], #]&;





              share|improve this answer






















              • 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














              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[##], #]&;





              share|improve this answer






















              • 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












              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[##], #]&;





              share|improve this answer














              You might define your own function cross, that calls Cross when the number of arguments is larger than 1:



              cross=If[Length[##]>1, Cross[##], #]&;






              share|improve this answer














              share|improve this answer



              share|improve this answer








              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 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















              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










              up vote
              5
              down vote













              An alternative solution without defining new functions:



              PrimeFactorization[x_] :=

              Superscript @@@ FactorInteger[x] /. y_ /; Length@y < 0 -> Cross @@ y





              share|improve this answer
























                up vote
                5
                down vote













                An alternative solution without defining new functions:



                PrimeFactorization[x_] :=

                Superscript @@@ FactorInteger[x] /. y_ /; Length@y < 0 -> Cross @@ y





                share|improve this answer






















                  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





                  share|improve this answer












                  An alternative solution without defining new functions:



                  PrimeFactorization[x_] :=

                  Superscript @@@ FactorInteger[x] /. y_ /; Length@y < 0 -> Cross @@ y






                  share|improve this answer












                  share|improve this answer



                  share|improve this answer










                  answered Aug 16 at 8:03









                  Fraccalo

                  2,184517




                  2,184517




















                      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!]


                      enter image description here






                      share|improve this answer




















                      • (+1) This does not resolve the issue with numbers that are a power if a prime though.
                        – Henrik Schumacher
                        Aug 16 at 16:59














                      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!]


                      enter image description here






                      share|improve this answer




















                      • (+1) This does not resolve the issue with numbers that are a power if a prime though.
                        – Henrik Schumacher
                        Aug 16 at 16:59












                      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!]


                      enter image description here






                      share|improve this answer












                      For displaying purposes you can also use:



                      Times @@ Defer@*Power @@@ FactorInteger[10!]

                      CenterDot @@ Superscript @@@ FactorInteger[10!]

                      Inactive[Times] @@ Superscript @@@ FactorInteger[10!]


                      enter image description here







                      share|improve this answer












                      share|improve this answer



                      share|improve this answer










                      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
















                      • (+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










                      up vote
                      2
                      down vote













                      You can use Block in two ways:



                      1. temporarily re-define Cross so that Cross[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$




                      1. temporarily define Sequence as Cross:



                      PrimeFactorization2[x_] := Block[Sequence = Cross,
                      ## & @@ Superscript @@@ FactorInteger @ x];

                      PrimeFactorization2 /@ 211, 222, 223 // TeXForm



                      $left211^1,2^1times 3^1times 37^1,223^1right$







                      share|improve this answer






















                      • I already up voted this answer! The proof (click).
                        – Friendly Ghost
                        Aug 17 at 13:23















                      up vote
                      2
                      down vote













                      You can use Block in two ways:



                      1. temporarily re-define Cross so that Cross[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$




                      1. temporarily define Sequence as Cross:



                      PrimeFactorization2[x_] := Block[Sequence = Cross,
                      ## & @@ Superscript @@@ FactorInteger @ x];

                      PrimeFactorization2 /@ 211, 222, 223 // TeXForm



                      $left211^1,2^1times 3^1times 37^1,223^1right$







                      share|improve this answer






















                      • I already up voted this answer! The proof (click).
                        – Friendly Ghost
                        Aug 17 at 13:23













                      up vote
                      2
                      down vote










                      up vote
                      2
                      down vote









                      You can use Block in two ways:



                      1. temporarily re-define Cross so that Cross[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$




                      1. temporarily define Sequence as Cross:



                      PrimeFactorization2[x_] := Block[Sequence = Cross,
                      ## & @@ Superscript @@@ FactorInteger @ x];

                      PrimeFactorization2 /@ 211, 222, 223 // TeXForm



                      $left211^1,2^1times 3^1times 37^1,223^1right$







                      share|improve this answer














                      You can use Block in two ways:



                      1. temporarily re-define Cross so that Cross[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$




                      1. temporarily define Sequence as Cross:



                      PrimeFactorization2[x_] := Block[Sequence = Cross,
                      ## & @@ Superscript @@@ FactorInteger @ x];

                      PrimeFactorization2 /@ 211, 222, 223 // TeXForm



                      $left211^1,2^1times 3^1times 37^1,223^1right$








                      share|improve this answer














                      share|improve this answer



                      share|improve this answer








                      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

















                      • 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


















                       

                      draft saved


                      draft discarded















































                       


                      draft saved


                      draft discarded














                      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













































































                      Comments

                      Popular posts from this blog

                      What does second last employer means? [closed]

                      List of Gilmore Girls characters

                      Confectionery