seq1 := (a, b, c); seq1[[1..2]]

Messages in english

Modérateur : xcasadmin

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

seq1 := (a, b, c); seq1[[1..2]]

Message par compsystems » dim. janv. 06, 2019 9:19 pm

Hello BP

seq1 := a, b, c
seq1[ 0 ] [↵] returns a
seq1[[ 1 ]] [↵] returns a
seq1[ 1 ] [↵] returns b
seq1[ 0..1 ] [↵] returns (a,b)
seq1[[1..2]] [↵] returns "invalid dimension" Why?
seq1[:] [↵] returns (a,b,c)
seq1[ : ] [↵] returns (a,b,c)[undef] Why?

session Xcas, sequences

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

Re: seq1 := (a, b, c); seq1[[1..2]]

Message par parisse » lun. janv. 07, 2019 7:10 pm

compsystems a écrit :
dim. janv. 06, 2019 9:19 pm
seq1[[1..2]] [↵] returns "invalid dimension" Why?
Double [[]] are not supported with ..
seq1[ : ] [↵] returns (a,b,c)[undef] Why?
[:] is recognized, but that's all. There is no reason to add spaces!

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

Re: seq1 := (a, b, c); seq1[[1..2]]

Message par compsystems » lun. janv. 07, 2019 10:31 pm

parisse a écrit :
lun. janv. 07, 2019 7:10 pm
compsystems a écrit :
dim. janv. 06, 2019 9:19 pm
seq1[[1..2]] [↵] returns "invalid dimension" Why?
Double [[]] are not supported with ..
seq1[ : ] [↵] returns (a,b,c)[undef] Why?
[:] is recognized, but that's all. There is no reason to add spaces!
...with sequences
there are algorithms in which sometimes it is better to index in 0 and others in 1, this avoids addition and subtraction of variables, a great idea to use [] or [[ ]] for that purpose.


The use of spaces is intended to give greater readability to expressions, every book of all the sciences shows that after a comma is a space, an improvement in the future, it would be to show the expressions of output not together 1,2,3 but 1, 2, 3 and even the operators a+(b*c) => a + (b * c)
at least for a flag controlled by the user, that is to say who does not mind seeing everything together or who wants to see the separate expressions

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

Re: seq1 := (a, b, c); seq1[[1..2]]

Message par parisse » mar. janv. 08, 2019 9:39 am

I will add support for [[a..b]]
I will not change output. Anyway, I don't like the idea that spaces should be added before/after operators.

Répondre