You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
24 lines
552 B
Python
24 lines
552 B
Python
#!/usr/bin/env python3
|
|
from functools import reduce
|
|
|
|
from sympy import latex, simplify
|
|
from sympy import pi, sin, cos, tan
|
|
|
|
|
|
def anki_latex(e):
|
|
"""Format SymPy expression as Anki LaTeX"""
|
|
return "[$$]" + latex(e) + "[/$$]"
|
|
|
|
|
|
def as_csv(*values):
|
|
return reduce(lambda a, b: a + ";" + b, values)
|
|
|
|
|
|
xs = map(simplify,
|
|
[i * pi / 4 for i in range(-16, 16)])
|
|
|
|
for x in xs:
|
|
for f in [sin, cos, tan]:
|
|
front = "What is " + anki_latex(f(x, evaluate=False)) + "?"
|
|
back = anki_latex(f(x))
|
|
print(as_csv(front, back)) |