[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Axiom-math] Assigning elements in a list of lists
From: |
Ralf Hemmecke |
Subject: |
Re: [Axiom-math] Assigning elements in a list of lists |
Date: |
Wed, 12 Nov 2008 12:58:08 +0100 |
User-agent: |
Thunderbird 2.0.0.17 (X11/20080914) |
On 11/12/2008 11:42 AM, Fabio S. wrote:
I can't understand why I am not able to assign an element in a list of
lists like in
--------
(35) -> A:=[[0,0,0,0]]
(35) [[0,0,0,0]] Type: List List NonNegativeInteger
(36) -> A(1,1)
(36) 0 Type: NonNegativeInteger
(37) -> A(1,1):=1
The form on the left hand side of an assignment must be a single
variable, a Tuple of variables or a reference to an entry in an object
supporting the setelt operation.
--------
I have not looked into the actual sources, but I'd guess, that there is
no function of the form
setelt: (%,Integer,Integer,R) -> R
-- will become setelt_!
++ setelt(m,i,j,r) sets the element in the ith row and jth
++ column of m to r
++ error check to determine if indices are in proper ranges
(which you find in array2.spad (TwoDimensionalArrayCategory)) in exports
of List. There is only
if % has shallowlyMutable then
setelt : (%, Dom, Im) -> Im
++ setelt(u,x,y) sets the image of x to be y under u,
++ assuming x is in the domain of u.
++ Error: if x is not in the domain of u.
-- this function will soon be renamed as setelt!.
from aggcat.spad (EltableAggregate) that looks available to me.
whereas if I declare A as a matrix it works:
--------
(43) -> A:=[[0,0,0,0]] :: Matrix INT
(43) [0 0 0 Type: Matrix Integer
(44) -> A(1,1):=1
(44) 1 Type: PositiveInteger
(45) -> A
(45) [1 0 0 0] Type: Matrix Integer
--------
Can anybody please explain me what is wrong in the first esample?
The above explains, why it works for matrices, since there
setelt: (%,Integer,Integer,R) -> R
is defined.
How to work around?
(2) -> A:=[[0,0,0,0]]
(2) [[0,0,0,0]]
Type: List(List(NonNegativeInteger))
(3) -> B:=A.1
(3) [0,0,0,0]
Type: List(NonNegativeInteger)
(4) -> B.1:=1
(4) 1
Type: PositiveInteger
(5) -> A
(5) [[1,0,0,0]]
Type: List(List(NonNegativeInteger))
(6) -> setelt(A.1,2,3)
(6) 3
Type: PositiveInteger
(7) -> A
(7) [[1,3,0,0]]
Type: List(List(NonNegativeInteger))
I somehow think, that this here...
(8) -> (A.1).3 :=4
The form on the left hand side of an assignment must be a single
variable, a Tuple of variables or a reference to an entry in an
object supporting the setelt operation.
should also work. Even A.1.3 := 4 should be OK, since is should
translate to setelt(elt(A, 1), 3, 4).
Ralf
>aldor -gloop
Aldor
Copyright (c) 1990-2007 Aldor Software Organization Ltd (Aldor.org).
Release: Aldor(C) version 1.1.0 (trunk-23 AXL_EDIT_1_1_13_18=0) for
LINUX(glibc2.3)
Type "#int help" for more details.
Reading aldorinit.as...
... ... ... ...
%3 >> import from MachineInteger
%4 >> import from Integer, List Integer, List List Integer
%5 >> A:=[[0,0,0,0]]
[[0,0,0,0]] @ List(List(AldorInteger))
%6 >> A.1.3 := 4
4 @ AldorInteger
%7 >> A
[[0,0,4,0]] @ List(List(AldorInteger))