from sage.all import *
from functools import reduce
+
def legend_latex(obj):
"""
- Return the LaTeX representation of `obj`, but wrap it in dollar
+ Return the LaTeX representation of ``obj``, but wrap it in dollar
($) signs so that we can pass it directly to plot() et al. as a
legend label.
"""
return '$%s$' % latex(obj)
+
def product(factors):
"""
- Returns the product of the elements in the list `factors`. If the
- list is empty, we return 1.
+ Returns the product of the elements in the list ``factors``. If
+ the list is empty, we return 1.
- TESTS:
+ EXAMPLES:
Normal integer multiplication::
sage: product([x,y,z])
x*y*z
+ TESTS:
+
+ The empty product is the multiplicative identity (one)::
+
+ sage: product([])
+ 1
+
"""
return reduce(operator.mul, factors, 1)