On Aug 20, 11:08 pm, rjf <fate...@gmail.com> wrote:
> Totally separating variable names -- that is, names that can be
> assigned values, and
> symbols, that cannot be assigned (ever) could clarify matters, but I
> think that no CAS does this.

I'm not sure how you mean it, but it's probably the case that Sage
does something in that direction. Note, that the "k" in the first
example changes it's type! Watch:

sage: k = var('k')
sage: type(k)
<type 'sage.symbolic.expression.Expression'>

sage: ex = 1+k
sage: type(ex)
<type 'sage.symbolic.expression.Expression'>

sage: k = 42
sage: type(k)
<type 'sage.rings.integer.Integer'>

sage: ex(k = k)
43

Last command has two "k"s, the first one for substitution inside "ex",
for the symbolic variable, and the second k is from the "globals()"
namespace, i.e. the Integer 42 object. So, the "k" as an expression
cannot be assigned, it's only possible to produce and expression like
"k == 42" that has the meaning of it, but no actual assignment
happens.

sage: var('k') # symbolic expression again
k

sage: ex2 = k == 42

sage: ex2
k == 42

sage: type(ex2)
<type 'sage.symbolic.expression.Expression'>

sage: ex.subs_expr(ex2)
43

H
--~--~---------~--~----~------------~-------~--~----~
To post to this group, send an email to sage-devel@googlegroups.com
To unsubscribe from this group, send an email to 
sage-devel-unsubscr...@googlegroups.com
For more options, visit this group at http://groups.google.com/group/sage-devel
URLs: http://www.sagemath.org
-~----------~----~----~----~------~----~------~--~---

Reply via email to