We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 597754b commit 13f2391Copy full SHA for 13f2391
1 file changed
M2/Macaulay2/d/ctype.d
@@ -67,11 +67,12 @@ ismathoperator(c1:char, c2:char):bool := (
67
ismathoperator((int(uchar(c1)) << 8) | int(uchar(c2))));
68
69
export isvalidsymbol(s:string):bool := (
70
- if !isalpha(s.0) then return false;
71
- if ismathoperator(s.0, s.1) && length(s) == utf8charlength(s.0)
+ n := length(s);
+ if n > 0 && !isalpha(s.0) then return false;
72
+ if n > 1 && ismathoperator(s.0, s.1) && n == utf8charlength(s.0)
73
then return true;
- for i from 0 to length(s) - 1 do (
74
- if !isalnum(s.i) || ismathoperator(s.i, s.(i + 1))
+ for i from 0 to n - 1 do (
75
+ if !isalnum(s.i) || (n > i + 1 && ismathoperator(s.i, s.(i + 1)))
76
then return false);
77
true);
78
0 commit comments