First time here? Check out the FAQ!

Ask Your Question
0

How does sage manages same name variables

asked 5 years ago

Recruiter gravatar image

Says I have 2 matrix named M in different cells how do they affect each other? Can it be dangerous?

Preview: (hide)

1 Answer

Sort by » oldest newest most voted
1

answered 5 years ago

Sébastien gravatar image

updated 5 years ago

It does this:

sage: M = identity_matrix(2)
sage: M
[1 0]
[0 1]
sage: M = 4
sage: M
4

In the noteboook, the most recent evaluated cell with M= ... will erase the previous affectation of the variable M.

The magic function %whos returns a table of type/value for each current variables that are defined and as you see, only one value is assigned to each variable:

sage: %whos
Variable   Type                                Data/Info
--------------------------------------------------------
M          Integer                             4
Preview: (hide)
link

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

Stats

Asked: 5 years ago

Seen: 211 times

Last updated: Apr 26 '20