Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

How to return a list from callable symbolic expression

I was (wrongfully) expecting the return type of all of the following function calls to be the same, namely a list. Why does the callable symbolic expression (1) return a vector, and how to rewrite (1) such that it does return a list?

# (1)
sage: f(x) = [x,x]
# (2)
sage: g = lambda x: [x,x]
# (3)
sage: def h(x):
....:     return [x,x]

sage: type(f(x))
<class 'sage.modules.vector_symbolic_dense.Vector_symbolic_dense'>
sage: type(g(x))
<type 'list'>
sage: type(h(x))
<type 'list'>