MathGroup Archive 2012

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

Search the Archive

compact notation for NonCommutativeMultiply that supports cut and paste

  • To: mathgroup at smc.vnet.net
  • Subject: [mg127651] compact notation for NonCommutativeMultiply that supports cut and paste
  • From: tobiashagge at gmail.com
  • Date: Sat, 11 Aug 2012 04:31:32 -0400 (EDT)
  • Delivered-to: l-mathgroup@mail-archive0.wolfram.com
  • Delivered-to: l-mathgroup@wolfram.com
  • Delivered-to: mathgroup-newout@smc.vnet.net
  • Delivered-to: mathgroup-newsend@smc.vnet.net

Hello,

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.

Unprotect[NonCommutativeMultiply];
InfixNotation[ParsedBoxWrapper["\[Null]"], NonCommutativeMultiply];
NonCommutativeMultiply /:
  MakeBoxes[NonCommutativeMultiply[x__], StandardForm] :=
  RowBox[Riffle[(MakeBoxes[#, StandardForm]) & /@ {x},
    ConstantArray[
     "\[InvisibleSpace]\[Null]\[InvisibleSpace]",
     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.

Best,
Tobias



  • 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