Skip to content

Commit ca70e56

Browse files
committed
Fix #1423 Transpose - use unicode \uF3C7 instead of symbol ᵀ
Characters.isSymjaIdentifierStart(fCurrentChar) runs before any operator check. Since U+1D40 is a Unicode modifier letter, it is classified as an identifier start. The unicode character U+F3C7 is used for `Transpose`
1 parent 8d77b63 commit ca70e56

3 files changed

Lines changed: 21 additions & 4 deletions

File tree

symja_android_library/matheclipse-core/src/main/java/org/matheclipse/core/parser/ExprParserFactory.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -363,7 +363,7 @@ public IASTMutable createFunction(final IParserFactory factory, ExprParser parse
363363
"∍", // "SuchThat", 180, InfixExprOperator.RIGHT_ASSOCIATIVE),
364364
"∑", // "Sum", 325), //
365365
"∴", // "Therefore", 50, InfixExprOperator.RIGHT_ASSOCIATIVE),
366-
"", // "Transpose", 670),
366+
"\uF3C7", // "Transpose", 670),
367367
"⊥", // UpTee
368368

369369
"~"};
@@ -604,7 +604,7 @@ private static void init() {
604604
new InfixExprOperator("∍", "SuchThat", 180, InfixExprOperator.RIGHT_ASSOCIATIVE),
605605
new PrefixExprOperator("∑", "Sum", 325), //
606606
new InfixExprOperator("∴", "Therefore", 50, InfixExprOperator.RIGHT_ASSOCIATIVE),
607-
new PostfixExprOperator("", "Transpose", 670),
607+
new PostfixExprOperator("\uF3C7", "Transpose", 670),
608608
new InfixExprOperator("⊥", "UpTee", 197, InfixExprOperator.LEFT_ASSOCIATIVE),
609609

610610

symja_android_library/matheclipse-core/src/test/java/org/matheclipse/core/system/ExprParserTestCase.java

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@
33
import static org.junit.jupiter.api.Assertions.assertEquals;
44
import org.junit.jupiter.api.Test;
55
import org.matheclipse.core.eval.EvalEngine;
6+
import org.matheclipse.core.eval.ExprEvaluator;
7+
import org.matheclipse.core.form.output.OutputFormFactory;
68
import org.matheclipse.core.interfaces.IExpr;
79
import org.matheclipse.core.parser.ExprParser;
810

@@ -91,4 +93,19 @@ public void testParserForAll() {
9193
assertEquals("∀a", //
9294
result.toString());
9395
}
96+
97+
@Test
98+
public void testTransposeToString() {
99+
// Transpose(List(List(1, 2), List(3, 4), List(5, 6)))
100+
IExpr parse = new ExprEvaluator().parse("Transpose(List(List(1, 2), List(3, 4), List(5, 6)))");
101+
String s = parse.toString();
102+
103+
OutputFormFactory outputFormFactory = OutputFormFactory.get(true, false, 5, 5);
104+
String text = outputFormFactory.toString(parse);
105+
assertEquals(text, "{{1,2},{3,4},{5,6}}\uF3C7");
106+
107+
// now parse back
108+
IExpr parseBack = new ExprEvaluator().parse(text);
109+
assertEquals(parseBack.fullFormString(), "Transpose(List(List(1, 2), List(3, 4), List(5, 6)))");
110+
}
94111
}

symja_android_library/matheclipse-parser/src/main/java/org/matheclipse/parser/client/operator/ASTNodeFactory.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -324,7 +324,7 @@ public ASTNode createFunction(final INodeParserFactory factory, final ASTNode lh
324324
"∍", // "SuchThat", 180, InfixExprOperator.RIGHT_ASSOCIATIVE),
325325
"∑", // "Sum", 325), //
326326
"∴", // "Therefore", 50, InfixExprOperator.RIGHT_ASSOCIATIVE),
327-
"", // "Transpose", 670),
327+
"\uF3C7", // "Transpose", 670),
328328
"⊥", // UpTee
329329

330330
"~" // Tilde
@@ -478,7 +478,7 @@ private static void init() {
478478
new InfixOperator("∍", "SuchThat", 180, InfixOperator.RIGHT_ASSOCIATIVE), //
479479
new PrefixOperator("∑", "Sum", 325), //
480480
new InfixOperator("∴", "Therefore", 50, InfixOperator.RIGHT_ASSOCIATIVE), //
481-
new PostfixOperator("", "Transpose", 670), //
481+
new PostfixOperator("\uF3C7", "Transpose", 670), //
482482
new InfixOperator("⊥", "UpTee", 197, InfixOperator.LEFT_ASSOCIATIVE),
483483

484484
new TildeOperator("~", "§TILDE§", Precedence.TILDE_OPERATOR, InfixOperator.NONE),

0 commit comments

Comments
 (0)