dkl9 commited on 2023-204 11:07:46
Showing 2 changed files, with 47 additions and 0 deletions.
| ... | ... |
@@ -295,6 +295,10 @@ |
| 295 | 295 |
<td class="excode">fact2(n) = fact(2 * n)<br />succ(n) = n + 1<br />cat = fact2 / fact^2 / succ</td> |
| 296 | 296 |
<td>Catalan numbers by functional arithmetic<br />(assuming fact is already defined)</td> |
| 297 | 297 |
</tr> |
| 298 |
+ <tr> |
|
| 299 |
+ <td class="excode">latex[integers == filter(reals, (r => floor(r) == ceil(r)))]</td> |
|
| 300 |
+ <td>generate L<sub>A</sub>T<sub>E</sub>X for a weird definition of the integers</td> |
|
| 301 |
+ </tr> |
|
| 298 | 302 |
</table> |
| 299 | 303 |
</details> |
| 300 | 304 |
<textarea id="bci" cols="120" rows="8"># Throw in some code ...</textarea><br /> |
| ... | ... |
@@ -96,6 +96,49 @@ RTensorRender.toLaTeX = function() {
|
| 96 | 96 |
} |
| 97 | 97 |
case 6: |
| 98 | 98 |
return `${this.l.toLaTeX()}[${this.m.toLaTeX()}]`;
|
| 99 |
+ case 7: |
|
| 100 |
+ case 8: |
|
| 101 |
+ const fa = this.m[0] ? this.m[0].toLaTeX() : "?"; |
|
| 102 |
+ const sa = this.m[1] ? this.m[1].toLaTeX() : "?"; |
|
| 103 |
+ const ta = this.m[2] ? this.m[2].toLaTeX() : "?"; |
|
| 104 |
+ const al = this.m.map(x => x.toLaTeX()); |
|
| 105 |
+ let ls = null; |
|
| 106 |
+ // special functions |
|
| 107 |
+ if (this.l.ts == 1) {
|
|
| 108 |
+ switch (this.l.v) {
|
|
| 109 |
+ case "abs": |
|
| 110 |
+ return `\\left|${fa}\\right|`;
|
|
| 111 |
+ case "all": |
|
| 112 |
+ ls = "\\wedge"; |
|
| 113 |
+ case "any": |
|
| 114 |
+ return `${al.map(x => lp + x + rp).join(` ${ls || "\\vee"} `)}`
|
|
| 115 |
+ case "approx": |
|
| 116 |
+ return `${fa} \\approx ${sa}`;
|
|
| 117 |
+ case "at": |
|
| 118 |
+ return `${lp}${fa}\\right|_{${sa}}^{${this.m[2] ? ta : ""}}`;
|
|
| 119 |
+ case "brace": |
|
| 120 |
+ return `\\left{${fa}\\right}`;
|
|
| 121 |
+ case "bracket": |
|
| 122 |
+ return `\\left[${fa}\\right]`;
|
|
| 123 |
+ case "ceil": |
|
| 124 |
+ return `\\lceil ${fa} \\rceil`;
|
|
| 125 |
+ case "cross": |
|
| 126 |
+ return `${fa} \\times ${sa}`;
|
|
| 127 |
+ case "dot": |
|
| 128 |
+ return `${fa} \\cdot ${sa}`;
|
|
| 129 |
+ case "fact": |
|
| 130 |
+ return this.m[0].shouldParenMul() ? `${lp}${fa}${rp}!` : `${fa}!`;
|
|
| 131 |
+ case "filter": |
|
| 132 |
+ return `\\left{x \\in ${fa} | ${sa}(x)\\right}`;
|
|
| 133 |
+ case "floor": |
|
| 134 |
+ return `\\lfloor ${fa} \\rfloor`;
|
|
| 135 |
+ case "hat": |
|
| 136 |
+ return `\\hat{${fa}}`;
|
|
| 137 |
+ // TODO: there's more! |
|
| 138 |
+ } |
|
| 139 |
+ } |
|
| 140 |
+ // anything else |
|
| 141 |
+ return `${this.l.toLaTeX()}(${al.join(", ")})`;
|
|
| 99 | 142 |
default: |
| 100 | 143 |
return "?"; |
| 101 | 144 |
} |
| 102 | 145 |