/usr/share/yacas/scripts/io.rep/print.ys is in yacas 1.3.6-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 | /* A reference print implementation. Expand at own leisure.
*
* This file implements Print, a scripted expression printer.
*/
/* 60000 is the maximum precedence allowed for operators */
10 # Print(_x) <--
[
Print(x,60000);
NewLine();
DumpErrors();
];
/* Print an argument within an environment of precedence n */
10 # Print(x_IsAtom,_n) <-- Write(x);
10 # Print(_x,_n)_(IsInfix(Type(x))And NrArgs(x) = 2) <--
[
Local(bracket);
bracket:= (OpPrecedence(Type(x)) > n);
If(bracket,WriteString("("));
Print(x[1],OpLeftPrecedence(Type(x)));
Write(x[0]);
Print(x[2],OpRightPrecedence(Type(x)));
If(bracket,WriteString(")"));
];
10 # Print(_x,_n)_(IsPrefix(Type(x)) And NrArgs(x) = 1) <--
[
Local(bracket);
bracket:= (OpPrecedence(Type(x)) > n);
Write(x[0]);
If(bracket,WriteString("("));
Print(x[1],OpRightPrecedence(Type(x)));
If(bracket,WriteString(")"));
];
10 # Print(_x,_n)_(IsPostfix(Type(x))And NrArgs(x) = 1) <--
[
Local(bracket);
bracket:= (OpPrecedence(Type(x)) > n);
If(bracket,WriteString("("));
Print(x[1],OpLeftPrecedence(Type(x)));
Write(x[0]);
If(bracket,WriteString(")"));
];
20 # Print(_x,_n)_(Type(x) = "List") <--
[
WriteString("{");
PrintArg(x);
WriteString("}");
];
20 # Print(_x,_n)_(Type(x) = "Prog") <--
[
WriteString("[");
PrintArgProg(Tail(Listify(x)));
WriteString("]");
];
20 # Print(_x,_n)_(Type(x) = "Nth") <--
[
Print(x[1],0);
WriteString("[");
Print(x[2],60000);
WriteString("]");
];
100 # Print(x_IsFunction,_n) <--
[
Write(x[0]);
WriteString("(");
PrintArg(Tail(Listify(x)));
WriteString(")");
];
/* Print the arguments of an ordinary function */
10 # PrintArg({}) <-- True;
20 # PrintArg(_list) <--
[
Print(Head(list),60000);
PrintArgComma(Tail(list));
];
10 # PrintArgComma({}) <-- True;
20 # PrintArgComma(_list) <--
[
WriteString(",");
Print(Head(list),60000);
PrintArgComma(Tail(list));
];
18 # Print(Complex(0,1),_n) <-- [WriteString("I");];
19 # Print(Complex(0,_y),_n) <-- [WriteString("I*");Print(y,4);];
19 # Print(Complex(_x,1),_n) <-- [Print(x,7);WriteString("+I");];
20 # Print(Complex(_x,_y),_n) <-- [Print(x,7);WriteString("+I*");Print(y,4);];
/* Tail-recursive printing the body of a compound statement */
10 # PrintArgProg({}) <-- True;
20 # PrintArgProg(_list) <--
[
Print(Head(list),60000);
WriteString(";");
PrintArgProg(Tail(list));
];
|