/usr/share/yacas/localrules.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 | RuleBase("<-",{left,right});
HoldArg("<-",left);
HoldArg("<-",right);
LocalSymbols(LocResult) [
Set(LocResult,True);
10 # LocPredicate(exp_IsAtom) <--
[
Local(tr,result);
tr:=patterns;
result:=False;
While (tr != {})
[
If (Head(Head(tr)) = exp,
[
Set(LocResult,Eval(Head(Tail(Head(tr)))));
result := True;
tr:={};
],
[
tr := Tail(tr);
]);
];
result;
];
10 # LocPredicate(exp_IsFunction) <--
[
Local(tr,result,head);
tr:=patterns;
result:=False;
While (tr != {})
[
Set(head, Head(Head(tr)));
If (Not(IsAtom(head)) And exp[0]=head[1] And Pattern'Matches(head[2], exp),
[
Set(LocResult,Eval(Head(Tail(Head(tr)))));
Set(result, True);
Set(tr,{});
],
[
Set(tr, Tail(tr));
]);
];
result;
];
20 # LocPredicate(_exp) <-- False;
LocChange(_exp) <-- LocResult;
]; // LocalSymbols(LocResult)
UnFence("LocPredicate",1);
UnFence("LocChange",1);
10 # LocProcessSingle({_pat,_post,_exp}) <-- { {pat[0],Pattern'Create(pat,post)},exp };
20 # LocProcessSingle({pat_IsFunction,_exp}) <-- { {pat[0],Pattern'Create(pat,True)},exp };
30 # LocProcessSingle({pat_IsAtom,_exp}) <-- { pat,exp };
40 # LocProcessSingle(pat_IsFunction <- _exp) <-- { {pat[0],Pattern'Create(pat,True)},exp };
50 # LocProcessSingle(pat_IsAtom <- _exp) <-- { pat,exp };
LocProcess(patterns) :=
[
MapSingle("LocProcessSingle",patterns);
];
CompilePatterns(patterns) := LocPatterns(LocProcess(patterns));
5 # (_expression /: LocPatterns(_patterns)) <--
[
MacroSubstitute(expression,"LocPredicate","LocChange");
];
10 # (_expression /: _patterns) <--
[
Set(patterns, LocProcess(patterns));
MacroSubstitute(expression,"LocPredicate","LocChange");
];
5 # (_expression /:: LocPatterns(_patterns)) <--
[
MacroSubstitute(expression,"LocPredicate","LocChange");
];
10 # (_expression /:: _patterns) <--
[
Local(old);
Set(patterns, LocProcess(patterns));
Set(old, expression);
Set(expression, MacroSubstitute(expression,"LocPredicate","LocChange"));
While (expression != old)
[
Set(old, expression);
Set(expression, MacroSubstitute(expression,"LocPredicate","LocChange"));
];
expression;
];
RuleBase("Where",{left,right});
//HoldArg("Where",left);
//HoldArg("Where",right);
UnFence("Where",2);
10 # (_body Where var_IsAtom == _value)
<-- `[Local(@var);@var := @value;@body;];
20 # (_body Where (_a And _b))
<--
[
Set(body,`(@body Where @a));
`(@body Where @b);
];
30 # (_body Where {}) <-- {};
40 # (_body Where list_IsList)_IsList(list[1])
<--
[
Local(head,rest);
head:=Head(list);
rest:=Tail(list);
rest:= `(@body Where @rest);
`(@body Where @head) : rest;
];
50 # (_body Where list_IsList)
<--
[
Local(head,rest);
While (list != {})
[
head:=Head(list);
body := `(@body Where @head);
list:=Tail(list);
];
body;
];
60 # (_body Where _var == _value) <-- Subst(var,value)body;
// (a or b) and (c or d) -> (a and c) or (a and d) or (b and c) or (b and d)
20 # (list_IsList AddTo _rest) <--
[
Local(res);
res:={};
ForEach(item,list)
[
res := Concat(res,item AddTo rest);
];
res;
];
30 # (_a'item AddTo list_IsList) <--
[
MapSingle({{orig},a'item And orig},list);
];
40 # (_a'item AddTo _b) <-- a'item And b;
|