table data
|
02-22-2019, 12:23 AM
(This post was last modified: 04-25-2019 02:31 AM by compsystems.)
Post: #1
|
|||
|
|||
table data
Hello,
Python has an object type called DICTIONARY that in xcas / hpprime is table(), but python, only manages a few types of data in relation to xcas, which can operate with many more and powerfull math types. Examples of use PHP Code: tblA := table( "float_1" = 5.0 , "integer_2" = 5, "complex_4" = 3+4*i, "identifier_6" = var01, "list_7" = [9,[8,7],[6,5,4]], "symbolic_8" = x+y*i , "rational_9" = 3/4, "string_12" = "Hello", "set_2" = set[ a, b ,a, c ], "polynomial_10" = poly1[ 1, -6, 11, -6 ] , "matrix" = [[1,2],[3,4]], "vector" = [9,8,7,6,5,4], "function_13" = f(x):=x+1 ) |
|||
02-22-2019, 04:00 PM
(This post was last modified: 02-22-2019 04:01 PM by toml_12953.)
Post: #2
|
|||
|
|||
RE: table() data
I get a syntax error and the cursor points after the var01 here:
tblA := table( "float_1" = 5.0 , "integer_2" = 5, "complex_4" = 3+4*i, "identifier_6" = var01 Tom L Cui bono? |
|||
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], table(MA) [enter] returns PHP Code: table( for the inverse process, that is, convert a table to a matrix, Note that this must have the form PHP Code: table( or PHP Code: table( Example PHP Code: matrix( ) or PHP Code: matrix( PHP Code: [[9,8], ///////////////////////// An alternative way to define tables is using ( : ) PHP Code: d := table( "foo": 10, 9:x+y*i, "bar": 100, "baz": 1000) [enter] returns But unlike python, Xcas reorders the labels numerically and alphabetically To extract the tag you can use FOR PHP Code: for k in d: and to access the values of the label. PHP Code: for k in d: |
|||
« Next Oldest | Next Newest »
|
User(s) browsing this thread: 1 Guest(s)