Created
June 7, 2022 03:23
-
-
Save shanehh/3ba1112315e574687b32f468219cc0f2 to your computer and use it in GitHub Desktop.
python scripts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
""" | |
change `$` delimiter to `\(` and `\)` pair, at mathjax | |
""" | |
import itertools | |
delimiters = iter(itertools.cycle(["\(", "\)"])) | |
# from https://math.stackexchange.com/questions/3307627 | |
original = r"""The point is that all rational numbers can be expressed in lowest terms. They don't have to be. Yes, $\frac 24$ is a perfectly good rational number, but the same number can be expressed as $\frac 12$. When we prove $\sqrt 2$ is irrational, we assume it is rational, then say to express that rational in lowest terms as $\frac ab$. The reason to do that is that we then show both $a$ and $b$ are even, so $\frac ab$ is not in lowest terms. If we had not assumed it was in lowest terms we would not have the contradiction we are seeking.""" | |
new = "" | |
for char in original: | |
if char == "$": | |
new += next(delimiters) | |
else: | |
new += char | |
print(new) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment