Restructure
parent
c31c800edf
commit
c085482492
@ -1,16 +1,24 @@
|
|||||||
#!/usr/bin/env python2.7
|
#!/usr/bin/env python3
|
||||||
from sympy import Symbol, latex, simplify
|
from functools import reduce
|
||||||
|
|
||||||
|
from sympy import latex, simplify
|
||||||
from sympy import pi, sin, cos, tan
|
from sympy import pi, sin, cos, tan
|
||||||
|
|
||||||
def ankilatex(e):
|
|
||||||
""" Format sympy expression as Anki LaTeX"""
|
|
||||||
return "[$$]" + latex(e) + "[/$$]"
|
|
||||||
|
|
||||||
for i in range(-16, 16):
|
def anki_latex(e):
|
||||||
x = simplify(i*pi/4)
|
"""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 f in [sin, cos, tan]:
|
for x in xs:
|
||||||
print "What is " + ankilatex(f(x, evaluate=False)) + "?",
|
for f in [sin, cos, tan]:
|
||||||
print ";",
|
front = "What is " + anki_latex(f(x, evaluate=False)) + "?"
|
||||||
print ankilatex(f(x)),
|
back = anki_latex(f(x))
|
||||||
print
|
print(as_csv(front, back))
|
Loading…
Reference in New Issue