hello, many of the outputs of the Python procedures are sequences, to be able to print the object as a single entity you have to convert it into a list,
list( (1,2) ) # python returns [1,2]
in Xcas the function to convert a sequence in list is makevector(), for example makevector( (1,2) ) or makevector( 1,2 ) returns [1,2], for compatibility please can create the list() alias of makevector()
thank you
PD: other functional aliases can be
set() converts a sequence into set: set( "a", "a", "b", "c", "a" ) > set[ "a", "b", "c"]
poly1() converts a sequence into a polynomial of a variable: poly1( 1, -6, 11, -6 ) > poly1[ 1, -6, 11, -6 ]
seq1:=1, -6, 11, -6
poly1(seq1) > poly1[ 1, -6, 11, -6 ]
Note: on some keyboards other than the English language you have to press two simultaneous keys plus a third to obtain "[" or "]" in this way it is faster to enter mathematic objects using functional commands with parentheses ()
list(), set(), poly1()
Modérateur : xcasadmin
-
- Messages : 562
- Inscription : sam. févr. 04, 2017 11:34 pm
- Localisation : Colombia
- Contact :
Re: list(), set(), poly1()
I don't know if it's possible for list, because list is an integer (value 256).
-
- Messages : 562
- Inscription : sam. févr. 04, 2017 11:34 pm
- Localisation : Colombia
- Contact :
Re: list(), set(), poly1()
In the following case list() works as a function.
vowelString = "aeiou"
list(vowelString) > [ "a","e","i","o","u" ]
vowelString = "aeiou"
list(vowelString) > [ "a","e","i","o","u" ]
-
- Messages : 562
- Inscription : sam. févr. 04, 2017 11:34 pm
- Localisation : Colombia
- Contact :
Re: list(), set(), poly1()
Hello BP, for python syntax
vowelString = "aeioua"
list(vowelString) > [ "a","e","i","o","u","a" ] #ok
set(vowelString) > set[ "a","e","i","o","u" ] # expected
Another case
strList := ["one", "two","three","one"]
numbersList := [1, 2, 3,1]
result = zip(strList,numbersList) >
[
["one",1],
["two",2],
["three",3]
["one",1]
] #ok
result= set(result) >
set[
["one",1],
["two",2],
["three",3]
] # expected
vowelString = "aeioua"
list(vowelString) > [ "a","e","i","o","u","a" ] #ok
set(vowelString) > set[ "a","e","i","o","u" ] # expected
Another case
strList := ["one", "two","three","one"]
numbersList := [1, 2, 3,1]
result = zip(strList,numbersList) >
[
["one",1],
["two",2],
["three",3]
["one",1]
] #ok
result= set(result) >
set[
["one",1],
["two",2],
["three",3]
] # expected