Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
sagemath
GitHub Repository: sagemath/sagelib
Path: blob/master/sage/misc/defaults.py
4044 views
1
"""
2
Defaults
3
4
AUTHORS: William Stein and David Kohel
5
"""
6
7
#*****************************************************************************
8
# Copyright (C) 2004 William Stein <[email protected]>
9
#
10
# Distributed under the terms of the GNU General Public License (GPL)
11
#
12
# This code is distributed in the hope that it will be useful,
13
# but WITHOUT ANY WARRANTY; without even the implied warranty of
14
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15
# General Public License for more details.
16
#
17
# The full text of the GPL is available at:
18
#
19
# http://www.gnu.org/licenses/
20
#*****************************************************************************
21
22
# default variable name
23
var_name = 'x'
24
25
26
27
def variable_names(n, name=None):
28
if name is None:
29
name = var_name
30
n = int(n)
31
if n == 1:
32
return [name]
33
return tuple(['%s%s'%(name,i) for i in range(n)])
34
35
def latex_variable_names(n, name=None):
36
if name is None:
37
name = var_name
38
n = int(n)
39
if n == 1:
40
return [name]
41
v = tuple(['%s_{%s}'%(name,i) for i in range(n)])
42
return v
43
44
def set_default_variable_name(name, separator=''):
45
r"""
46
Change the default variable name and separator.
47
"""
48
global var_name, var_sep
49
var_name = str(name)
50
var_sep = str(separator)
51
52