list(), set(), poly1()

Messages in english

Modérateur : xcasadmin

compsystems
Messages : 562
Inscription : sam. févr. 04, 2017 11:34 pm
Localisation : Colombia
Contact :

list(), set(), poly1()

Message par compsystems » ven. mars 15, 2019 2:12 pm

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 ()

parisse
Messages : 5739
Inscription : mar. déc. 20, 2005 4:02 pm
Contact :

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

Message par parisse » ven. mars 15, 2019 5:29 pm

I don't know if it's possible for list, because list is an integer (value 256).

compsystems
Messages : 562
Inscription : sam. févr. 04, 2017 11:34 pm
Localisation : Colombia
Contact :

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

Message par compsystems » jeu. mars 21, 2019 12:15 am

In the following case list() works as a function.

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

compsystems
Messages : 562
Inscription : sam. févr. 04, 2017 11:34 pm
Localisation : Colombia
Contact :

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

Message par compsystems » jeu. mars 28, 2019 12:49 am

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

Répondre