Page 1 sur 1

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

Publié : dim. janv. 06, 2019 9:19 pm
par compsystems
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

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

Publié : lun. janv. 07, 2019 7:10 pm
par parisse
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!

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

Publié : lun. janv. 07, 2019 10:31 pm
par compsystems
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

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

Publié : mar. janv. 08, 2019 9:39 am
par parisse
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.