The bracket notation used to find elements of sequences and lists can also be used to extract a range of elements. If S is a sequence or list of size n, then S[n1..n2] returns the subsequence or sublist of S consisting of the elements with indices from n1 to n2, where 0 ≤ n1≤ n2 < s (in Xcas syntax mode) or 0 < n1≤ n2 ≤ s in other syntax modes.
Examples.
⎡ ⎣ | 1,2,3 | ⎤ ⎦ |
B,C,D |
For lists, the at command can also be used to get a sublist.
Again, at can not be used for sequences.
Example.
Input:
Output:
⎡ ⎣ | 3,4,5 | ⎤ ⎦ |
An alternative to using at for finding a sublist is the mid command, which again cannot be used for sequences.
Examples.
⎡ ⎣ | 2,3,4 | ⎤ ⎦ |
⎡ ⎣ | 2,3,4,5 | ⎤ ⎦ |