Post Reply 
table data
02-22-2019, 07:33 PM (This post was last modified: 04-25-2019 02:49 AM by compsystems.)
Post: #3
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:
:= table"foo"109:x+y*i"bar"100"baz"1000) [enterreturns
table
(
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) [enterreturns

9
bar
baz
foo 



and to access the values of the label.
PHP Code:
for k in d:
    print(
d[k]) [enterreturns

x
+y*i
100
1000
10 
Find all posts by this user
Quote this message in a reply
Post Reply 


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



User(s) browsing this thread: 1 Guest(s)