Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

Guessing what you aim at ; its way easier to build expressions rather than concatenating strings :

# Unused for now...
# nl = 3 
# nc = 2 
ring = QQ
# A = matrix(ring,nl,nc,[3,2,1,4,1,1])
# b = vector(ring,[3,5,6])
c = vector(ring,[4,7])
X = var("x_", n=2)
Zer = [0]*len(X)
# Those operators are builtins but notr imported in the toplevel namespace
from _operator import le, ge
vsign = [ge]*2
LL = list(map(lambda u,v:u(*v), vsign, zip(X,Zer)))

will allow for :

sage: LL
[x_0 >= 0, x_1 >= 0]

or, if you really need strings :

sage: list(map(str, LL))
['x_0 >= 0', 'x_1 >= 0']

HTH,

Guessing what you aim at ; its way easier to build expressions rather than concatenating strings :

# Unused for now...
# nl = 3 
# nc = 2 
ring = QQ
# A = matrix(ring,nl,nc,[3,2,1,4,1,1])
# b = vector(ring,[3,5,6])
c = vector(ring,[4,7])
X = var("x_", n=2)
Zer = [0]*len(X)
# Those operators are builtins but notr not imported in the toplevel namespace
from _operator import le, ge
vsign = [ge]*2
LL = list(map(lambda u,v:u(*v), vsign, zip(X,Zer)))

will allow for :

sage: LL
[x_0 >= 0, x_1 >= 0]

or, if you really need strings :

sage: list(map(str, LL))
['x_0 >= 0', 'x_1 >= 0']

HTH,

Guessing what you aim at ; its it's way easier to build expressions rather than concatenating strings :

# Unused for now...
# nl = 3 
# nc = 2 
ring = QQ
# A = matrix(ring,nl,nc,[3,2,1,4,1,1])
# b = vector(ring,[3,5,6])
c = vector(ring,[4,7])
X = var("x_", n=2)
Zer = [0]*len(X)
# Those operators are builtins but not imported in the toplevel namespace
from _operator import le, ge
vsign = [ge]*2
LL = list(map(lambda u,v:u(*v), vsign, zip(X,Zer)))

will allow for :

sage: LL
[x_0 >= 0, x_1 >= 0]

or, if you really need strings :

sage: list(map(str, LL))
['x_0 >= 0', 'x_1 >= 0']

HTH,