This file is indexed.

/usr/share/yacas/deffunc.rep/code.ys is in yacas 1.3.3-2.

This file is owned by root:root, with mode 0o644.

The actual contents of the file can be viewed below.

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
/* Defining a macro-like function that declares a function
 * with only one rule.
 */
RuleBase("Function",{oper,args,body});
HoldArg("Function",oper);
HoldArg("Function",args);
HoldArg("Function",body);

RuleBase("Macro",{oper,args,body});
HoldArg("Macro",oper);
HoldArg("Macro",args);
HoldArg("Macro",body);

// function with variable number of arguments: Function("func",{x,y, ...})body;
Rule("Function",3,2047,
	And(GreaterThan(Length(args), 1), Equals( MathNth(args, Length(args)), Atom("...") ))
)
[
  DestructiveDelete(args,Length(args));	// remove trailing "..."
  Retract(oper,Length(args));
  MacroRuleBaseListed(oper,args);
  MacroRule(oper,Length(args),1025,True) body;	// at precedence 1025, for flexibility
];

// function with a fixed number of arguments
Rule("Function",3,2048,True)
[
  Retract(oper,Length(args));
  MacroRuleBase(oper,args);
  MacroRule(oper,Length(args),1025,True) body;
];


// macro with variable number of arguments: Macro("func",{x,y, ...})body;
Rule("Macro",3,2047,
	And(GreaterThan(Length(args), 1), Equals( MathNth(args, Length(args)), Atom("...") ))
)
[
  DestructiveDelete(args,Length(args));	// remove trailing "..."
  Retract(oper,Length(args));
  `DefMacroRuleBaseListed(@oper,@args);
  MacroRule(oper,Length(args),1025,True) body;	// at precedence 1025, for flexibility
];

// macro with a fixed number of arguments
Rule("Macro",3,2048,True)
[
  Retract(oper,Length(args));
  `DefMacroRuleBase(@oper,@args);
  MacroRule(oper,Length(args),1025,True) body;
];


/// shorthand function declarations
RuleBase("Function",{oper});
// function with variable number of arguments: Function() f(x,y, ...)
Rule("Function",1,2047,
	And(IsFunction(oper), GreaterThan(Length(oper), 1), Equals( MathNth(oper, Length(oper)), Atom("...") ))
)
[
	Local(args);
	Set(args,Tail(Listify(oper)));
	DestructiveDelete(args,Length(args));	// remove trailing "..."
	If(RuleBaseDefined(Type(oper),Length(args)),
		False,	// do nothing
		MacroRuleBaseListed(Type(oper),args)
	);
];
// function with a fixed number of arguments
Rule("Function",1,2048,
	And(IsFunction(oper))
)
[
	Local(args);
	Set(args,Tail(Listify(oper)));
	If(RuleBaseDefined(Type(oper),Length(args)),
		False,	// do nothing
		MacroRuleBase(Type(oper),args)
	);
];


RuleBase("Macro",{oper});
// macro with variable number of arguments: Macro() f(x,y, ...)
Rule("Macro",1,2047,
	And(IsFunction(oper), GreaterThan(Length(oper), 1), Equals( MathNth(oper, Length(oper)), Atom("...") ))
)
[
	Local(args,name);
	Set(args,Tail(Listify(oper)));
	DestructiveDelete(args,Length(args));	// remove trailing "..."
  Set(name,Type(oper));
	If(RuleBaseDefined(Type(oper),Length(args)),
		False,	// do nothing
		`DefMacroRuleBaseListed(@name,@args)
	);
];
// macro with a fixed number of arguments
Rule("Macro",1,2048,
	And(IsFunction(oper))
)
[
	Local(args,name);
	Set(args,Tail(Listify(oper)));
  Set(name,Type(oper));
	If(RuleBaseDefined(Type(oper),Length(args)),
		False,	// do nothing
		[
      `DefMacroRuleBase(@name,@args);
    ]
	);
];


RuleBase("TemplateFunction",{oper,args,body});
Bodied("TemplateFunction",60000);
HoldArg("TemplateFunction",oper);
HoldArg("TemplateFunction",args);
HoldArg("TemplateFunction",body);
Rule("TemplateFunction",3,2047,True)
[
  Retract(oper,Length(args)); 
  Local(arglist);
  arglist:=FlatCopy(args);
  
  DestructiveAppend(arglist,{args,UnList({Hold,body})});
  arglist:=ApplyPure("LocalSymbols",arglist);

  MacroRuleBase(oper,arglist[1]);
  MacroRule(oper,Length(args),1025,True) arglist[2];

];

Function("HoldArgNr",{function,arity,index})
[
  Local(args);
  args:=RuleBaseArgList(function,arity);
/* Echo({"holdnr ",args}); */
  ApplyPure("HoldArg",{function,args[index]});
];



/* := assignment. */
RuleBase(":=",{aLeftAssign,aRightAssign});
UnFence(":=",2);
HoldArg(":=",aLeftAssign);
HoldArg(":=",aRightAssign);

/* := assignment. */
// assign a variable
Rule(":=",2,0,IsAtom(aLeftAssign))
[
  MacroSet(aLeftAssign,Eval(aRightAssign));
  Eval(aLeftAssign);
];

// assign lists
Rule(":=",2,0,IsList(aLeftAssign))
[
  Map(":=",{aLeftAssign,Eval(aRightAssign)});
];

// auxiliary function to help assign arrays using :=
RuleBase("AssignArray",{setlistterm,setlistindex,setlistresult});
UnFence("AssignArray",3);
Rule("AssignArray",3,1,IsString(setlistindex))
[
  Local(item);
  item:=Assoc(setlistindex,setlistterm);
  If(item = Empty,
     DestructiveInsert(setlistterm,1,{setlistindex,setlistresult}),
     DestructiveReplace(item,2,setlistresult)
     );
  True;
];
// assign generic arrays
Rule("AssignArray",3,1,
   And(
           Equals(IsGeneric(setlistterm),True),
           Equals(GenericTypeName(setlistterm),"Array")
          )
    )
[
  Array'Set(setlistterm,setlistindex,setlistresult);
];


Rule("AssignArray",3,2,True)
[
  DestructiveReplace(setlistterm ,setlistindex, setlistresult);
  True;
];

// a[x] := ... assigns to an array element
Rule(":=",2,10,IsFunction(aLeftAssign) And (Head(Listify(aLeftAssign)) = Nth))
[
 Local(frst,scnd);

 Local(lst);
 Set(lst,(Listify(aLeftAssign)));
 Set(lst,Tail(lst));
 Set(frst, Eval(Head(lst)));
 Set(lst,Tail(lst));
 Set(scnd, Eval(Head(lst)));

 AssignArray(frst,scnd,Eval(aRightAssign));
];

// f(x):=... defines a new function
Rule(":=",2,30,IsFunction(aLeftAssign) And Not(Equals(aLeftAssign[0], Atom(":="))))
[
  Local(oper,args,arity);
  Set(oper,String(aLeftAssign[0]));
  Set(args,Tail(Listify(aLeftAssign)));
  If(
	And(GreaterThan(Length(args), 1), Equals( MathNth(args, Length(args)), Atom("...") )),
	// function with variable number of arguments
	[
	  DestructiveDelete(args,Length(args));	// remove trailing "..."
	  Set(arity,Length(args));
	  Retract(oper,arity); 
	  MacroRuleBaseListed(oper, args);
	],
	// function with a fixed number of arguments
	[
	  Set(arity,Length(args));
	  Retract(oper,arity); 
	  MacroRuleBase(oper, args);
	]
  );
  UnHoldable(aRightAssign);
  MacroRule(oper,arity,1025,True) aRightAssign;
];

// this will "unhold" a variable - used to make sure that := with Eval()
// immediately on the right hand side evaluates its argument
RuleBase("UnHoldable",{var});
HoldArg("UnHoldable",var);
UnFence("UnHoldable",1);
Rule("UnHoldable",1,10,Equals(Type(Eval(var)),"Eval"))
[
  MacroSet(var,Eval(Eval(var)));
/* Echo({"unheld",var,Eval(var)}); */
];
Rule("UnHoldable",1,20,True)
[
/* Echo({"held"}); */
  True;
];