[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Axiom-developer] About mutable and functions.
From: |
Francois Maltey |
Subject: |
[Axiom-developer] About mutable and functions. |
Date: |
01 Nov 2007 09:31:46 +0100 |
User-agent: |
Gnus/5.09 (Gnus v5.9.0) Emacs/21.4 |
I like this discuss about mutable variables.
You know I also teach caml. I notice that the 2 manners "mutable data"
and "not-mutable" data must be separate.
If not, everybody make a lot of errors.
Functional languages, mathematics and not-mutable datas are very close.
What do you think about this concrete matrix example ?
A := matrix [[1,2],[3,4]]
fct A == .... A.(1,1) := 10 .... and the result is a number or others.
Mathematics say that both 3*A matrices bellow are equal :
The variable A is the same and we don't see any assin command.
3*A
fct A
3*A --- ve verify the matrix.
We don't understand why A changes.
First we think about the result of fct, not about the manner we get it.
Is it possible to have an automatic copy of the variables in a function ?
On the other hand, if we want to code a matrix sequence we write :
M := matrix [[...]]
fct A == ...A.(1,1):=A.... A -- this A is the result, the new matrix.
M := fct M
M := fct M -- to iterate.
The time for copying data-structure isn't so long that we must think
everytime about it. Axiom is designed for mathematics.
Axiom Guru's find obvious to code
fct M == A:=copy M ... .... in the first case.
fct A == A.(1,1) := 12 .... A in the second case.
and it's a little faster.
But that forces to teach what are mutable/not-mutable data
in the first courses of axiom.
This isn't the aim of axiom which is a mathematical language.
fct A == ... .... axiom copy the matrix.
fct A == A.(1,1) := 12 .... A the outer M := explains the matrix change.
Maple use a silly evalm matrix command.
And I never get difficult with mupad which copy data structure by default.
And what do you think about lists ?
My first thought for mathematics thinks that lists aren't mutable.
But list becomes mutable with L.3 := 33. This assign command is too easy.
A setelt! (L, 3, 33) doesn't hide the same difficult.
Francois.
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Axiom-developer] About mutable and functions.,
Francois Maltey <=