table data - Printable Version +- HP Forums (https://www.hpmuseum.org/forum) +-- Forum: HP Calculators (and very old HP Computers) (/forum-3.html) +--- Forum: HP Prime (/forum-5.html) +--- Thread: table data (/thread-12477.html) |
table data - compsystems - 02-22-2019 12:23 AM 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 ) RE: table() data - toml_12953 - 02-22-2019 04:00 PM 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 RE: table() data - compsystems - 02-22-2019 07:33 PM 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: |