table data
02-22-2019, 07:33 PM (This post was last modified: 04-25-2019 02:49 AM by compsystems.)
Post: #3
 compsystems Senior Member Posts: 1,384 Joined: Dec 2013
RE: table() data
Hello,
Delete the space between set and the bracket []
set [] => set[], same for polynomial poly1[], I do not know why the hpprime, when pasting the data adds a space before []

##################

Converting a rectangular array type matrix into a table
the positions start at (0,0)

Example
PHP Code:
MA:=[[9,8],[7,3+4*i]]

table(MA) [enter] returns

PHP Code:
table((0,0) = 9,(0,1) = 8,(1,0) = 7,(1,1) = 3+4*i)

for the inverse process, that is, convert a table to a matrix, Note that this must have the form

PHP Code:
table((0,0) = element1,(0,1) = element2,...)

or

PHP Code:
table([0,0] = element1,[0,1] = element2,...)

Example

PHP Code:
matrix( table((0,0) = 9,(0,1) = 8,(1,0) = 7,(1,1) = 3+4*i)

)

or

PHP Code:
matrix( table([0,0] = 9,[0,1] = 8,[1,0] = 7,[1,1] = 3+4*i) )
[enter] returns

PHP Code:
[[9,8],[7,3+4*i]]

/////////////////////////

An alternative way to define tables is using ( : )
PHP Code:
d := table( "foo": 10, 9:x+y*i, "bar": 100, "baz": 1000) [enter] returnstable(9 = x+y*i,"bar" = 100,"baz" = 1000,"foo" = 10)

But unlike python, Xcas reorders the labels numerically and alphabetically

To extract the tag you can use FOR
PHP Code:
for k in d:   print(k) [enter] returns9barbazfoo

and to access the values of the label.
PHP Code:
for k in d:    print(d[k]) [enter] returnsx+y*i100100010
 « Next Oldest | Next Newest »

 Messages In This Thread table data - compsystems - 02-22-2019, 12:23 AM RE: table() data - toml_12953 - 02-22-2019, 04:00 PM RE: table() data - compsystems - 02-22-2019 07:33 PM