Page 1 sur 1

list(), set(), poly1()

Publié : ven. mars 15, 2019 2:12 pm
par compsystems
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 ()

Re: list(), set(), poly1()

Publié : ven. mars 15, 2019 5:29 pm
par parisse
I don't know if it's possible for list, because list is an integer (value 256).

Re: list(), set(), poly1()

Publié : jeu. mars 21, 2019 12:15 am
par compsystems
In the following case list() works as a function.

vowelString = "aeiou"
list(vowelString) > [ "a","e","i","o","u" ]

Re: list(), set(), poly1()

Publié : jeu. mars 28, 2019 12:49 am
par compsystems
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