MathGroup Archive 2012

[Date Index] [Thread Index] [Author Index]

Search the Archive

compact notation for NonCommutativeMultiply that supports cut and paste


I am doing some group theory computations that have output of the form

:= NonCommutativeMultiply[very-long-sequence-of-letters]

I want the StandardForm output to display as a string of symbols without spaces, just like the output of Times. I want to be able to copy and paste that output into an input line and have it be correctly interpreted. Finally, I want "a b" to evaluate as Times[a,b].

I decided to define the null character as an operator, piecing together bits of code from the internet.

InfixNotation[ParsedBoxWrapper["\[Null]"], NonCommutativeMultiply];
NonCommutativeMultiply /:
  MakeBoxes[NonCommutativeMultiply[x__], StandardForm] :=
  RowBox[Riffle[(MakeBoxes[#, StandardForm]) & /@ {x},
     Length[{x}] - 1]]];

I'm having two issues:
1) The special characters are not visible in the notebook, which makes the code a bit hard to read.
2) Letters appear spaced apart in the output. If you copy and paste the output, the spacing disappears (so pushing the letters together in the output using negative space will make copy/paste awkward).

Using AlignmentMarker instead of Null fixes the spacing issue. However, for reasons I do not understand, the InfixNotation command does not work in this case.

Any help or helpful advice is appreciated.


  • Prev by Date: Re: Nested numerical integral - speed: Is it suppose to be so slow?
  • Next by Date: Re: VectorPlot3D
  • Previous by thread: Re: VectorPlot3D
  • Next by thread: Re: compact notation for NonCommutativeMultiply that supports cut and paste