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


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

compact notation for NonCommutativeMultiply that supports cut and paste

Started bytobiashagge@gmail.com
First post2012-08-11 08:34 +0000
Last post2012-08-11 08:34 +0000
Articles 1 — 1 participant

Back to article view | Back to comp.soft-sys.math.mathematica


Contents

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

#11315 — compact notation for NonCommutativeMultiply that supports cut and paste

Fromtobiashagge@gmail.com
Date2012-08-11 08:34 +0000
Subjectcompact notation for NonCommutativeMultiply that supports cut and paste
Message-ID<k055e8$8ki$1@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

[toc] | [standalone]


Back to top | Article view | comp.soft-sys.math.mathematica


csiph-web