Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.soft-sys.math.mathematica > #11315

compact notation for NonCommutativeMultiply that supports cut and paste

From tobiashagge@gmail.com
Newsgroups comp.soft-sys.math.mathematica
Subject compact notation for NonCommutativeMultiply that supports cut and paste
Date 2012-08-11 08:34 +0000
Message-ID <k055e8$8ki$1@smc.vnet.net> (permalink)
Organization Time-Warner Telecom

Show all headers | View raw


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

Back to comp.soft-sys.math.mathematica | Previous | Next | Find similar | Unroll thread


Thread

compact notation for NonCommutativeMultiply that supports cut and paste tobiashagge@gmail.com - 2012-08-11 08:34 +0000

csiph-web