Skip to content

Commit

Permalink
minor keyword/symbol fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
pzinn committed Nov 28, 2024
1 parent d101352 commit 43b5d68
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 17 deletions.
7 changes: 6 additions & 1 deletion M2/Macaulay2/d/actors5.d
Original file line number Diff line number Diff line change
Expand Up @@ -1994,7 +1994,12 @@ functionBody(e:Expr):Expr := (
);
setupfun("functionBody",functionBody);

symbolBody(e:Expr):Expr := when e is s:SymbolClosure do Expr(SymbolBody(s.symbol)) else WrongArg("a symbol");
symbolBody(e:Expr):Expr := (
when e
is s:SymbolClosure do Expr(SymbolBody(s.symbol))
is s:SpecialExpr do symbolBody(s.e)
else WrongArg("a symbol")
);
setupfun("symbolBody",symbolBody);

dumpNodes(e:Expr):Expr := (dumpNodes(); nullE);
Expand Down
4 changes: 2 additions & 2 deletions M2/Macaulay2/d/binding.d
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,7 @@ unaryword(s:string) :Word := makeUniqueWord(s, parseinfo(prec,nopr
postfix(s:string) :Word := install(s,makeUniqueWord(s, parseinfo(prec,nopr ,nopr,parsefuns(errorunary,postfixop))));
unarybinaryleft(s:string) :Word := install(s,makeUniqueWord(s, parseinfo(prec,prec ,prec,parsefuns(unaryop ,binaryop))));
unarybinaryright(s:string) :Word := install(s,makeUniqueWord(s, parseinfo(prec,prec-1,prec,parsefuns(unaryop ,binaryop))));
export binaryleft(s:string) :Word := install(s,makeUniqueWord(s, parseinfo(prec,prec ,nopr,parsefuns(errorunary,binaryop))));
binaryleft(s:string) :Word := install(s,makeUniqueWord(s, parseinfo(prec,prec ,nopr,parsefuns(errorunary,binaryop))));
nright(s:string) :Word := install(s,makeUniqueWord(s, parseinfo(prec,prec-1,nopr,parsefuns(errorunary,nbinaryop))));
nleftword(s:string) :Word := makeUniqueWord(s, parseinfo(prec,prec ,nopr,parsefuns(errorunary,nbinaryop)));
nunarybinaryleft(s:string) :Word := install(s,makeUniqueWord(s, parseinfo(prec,prec ,prec,parsefuns(nnunaryop ,nbinaryop))));
Expand Down Expand Up @@ -190,7 +190,7 @@ special(s:string,f:function(Token,TokenFile,int,bool):ParseTree,lprec:int,rprec:
-- created below are all in the global dictionary.

-- new operators must be:
-- set up as an "actor" with "setup()"
-- set up as an "actor" with "setup()" -- or not TODO explain
-- added to the export list in ../m2/exports.m2
-- added to the table binaryOperatorFunctions in ../m2/expressions.m2
-- added to the list of operators in the documentation node "operators" in ../packages/Macaulay2Doc/ov_language.m2
Expand Down
23 changes: 9 additions & 14 deletions M2/Macaulay2/m2/expressions.m2
Original file line number Diff line number Diff line change
Expand Up @@ -1250,15 +1250,10 @@ net Set := net @@ expression
texMath Set := texMath @@ expression

-- shortening expressions
Dots = new Type of Symbol
cdots=new Dots from symbol cdots
ddots=new Dots from symbol ddots
vdots=new Dots from symbol vdots
ldots=new Dots from symbol ldots
texMath Dots := x -> "\\" | simpleToString x -- note that \vdots has bad spacing in ordinary LaTeX
toString Dots := x -> "..."
net Dots := x -> if x === vdots then "."||"."||"." else if x === ddots then ". "||" . "||" ." else "..."

⋯:=symbol
⋱:=symbol
⋮:=symbol
…:=symbol
-- used e.g. in chaincomplexes.m2
shortLength := 8
shortStringLength := 3*shortLength
Expand All @@ -1268,15 +1263,15 @@ short Holder := identity -- to avoid infinite loops
short MatrixExpression :=
short Table := x -> (
(opts,m) := matrixOpts x;
shortRow := row -> apply(if #row>shortLength then { first row, cdots, last row } else row,short);
shortRow := row -> apply(if #row>shortLength then { first row, , last row } else row,short);
new class x from
apply(if #m>shortLength then {first m,if #m#0>shortLength then {vdots,ddots,vdots} else toList(#m#0:vdots),last m}
apply(if #m>shortLength then {first m,if #m#0>shortLength then {⋮,⋱,⋮} else toList(#m#0:),last m}
else m,shortRow)
)
short VisibleList :=
short Expression := x -> apply(if #x>shortLength then new class x from {
first x,
if instance(x,VectorExpression) or instance(x,VerticalList) then vdots else if instance(x,VisibleList) then ldots else cdots,
if instance(x,VectorExpression) or instance(x,VerticalList) then else if instance(x,VisibleList) then else ,
last x
}
else x,short)
Expand All @@ -1285,12 +1280,12 @@ short String := s -> if #s > shortStringLength then substring(s,0,shortStringLen
short Net := n -> (if #n > shortLength then stack (apply(shortLength,i->short n#i) | {".",".",".",short last n}) else stack apply(unstack n,short))^(height n-1) -- same
short HashTable := H -> hold ( if #H <= shortLength then H else (
s := sortByName pairs H;
new class H from append(take(s,shortLength),s#shortLength#0=>cdots)
new class H from append(take(s,shortLength),s#shortLength#0=>)
))
short MutableHashTable := expression
short Set := H -> hold ( if #H <= shortLength then H else (
s := sort keys H;
new class H from append(take(s,shortLength),RowExpression{s#shortLength,ldots})
new class H from append(take(s,shortLength),RowExpression{s#shortLength,})
))

Abbreviate = new WrapperType of Holder -- only used once, for listSymbols
Expand Down

0 comments on commit 43b5d68

Please sign in to comment.