TI-BASIC:Seq List

From Learn @ Cemetech
Jump to navigationJump to search

SEQ-LIST.GIF

Command Summary

Creates a list by evaluating a formula with one variable taking on a range of values, optionally skipping by a specified step.

Command Syntax

seq(formula, variable, start-value, end-value [, step])

Menu Location

While editing a program, press:

  1. 2nd LIST to enter the LIST menu
  2. RIGHT to enter the OPS submenu
  3. 5 to choose seq(, or use arrows.

Calculator Compatibility

TI-83/84/+/SE

Token Size

1 byte

The seq( command is very powerful, as it is (almost) the only command that can create a whole list as output. This means that you will need make use of it almost every time that you use lists. The seq( command creates a list by evaluating a formula with one variable taking on a range of several values.

It is similar in this to the For( command, but unlike For(, instead of running a block of commands, it only evaluates a formula. Like the For( command, there is an optional "step" that you can use to get every 3rd, every 5th, etc. value in the range.

Some sample uses of the command:

:seq(I,I,3,7
  • evaluates the expression 'I' with I taking on the values 3..7
  • returns {3,4,5,6,7}
:seq(AX²,X,1,7
  • evaluates the expression 'AX²' with X taking on the values 1..7
  • returns {A,4A,9A,16A,25A,36A,49A}, depending on the value of A
:seq(Y1(T),T,1,9,2


  • evaluates the expression 'Y1(T)' with T taking on every 2nd value 1..9
  • returns {Y1(1),Y1(3),Y1(5),Y1(7),Y1(9)} depending on Y1

Note: the value of the variable used in the expression does not change. If X has some value stored to it, and you do a seq() command using X, X will still hold that original value. However, if X was undefined before the command, after the command, it will be defined and have a value of 0.

Advanced Uses

The step argument supplied can be negative. If it is, and if the starting value is greater than the ending value, then the sequence will "go backward", evaluating the expression in the opposite order. For example:


:seq(I,I,1,7
	{1,2,3,4,5,6,7}
:seq(I,I,7,1,-1
	{7,6,5,4,3,2,1}


You can use seq( to get a "sublist", that is, to get a list that is only a section of another list. This is pretty much the only effective way to extract a sublist. For example, to get the 2nd through 10th elements of L1, do the following:


:seq(L1(I),I,2,10


While using seq(, the calculator can still interpret keypresses and store them to GetKey. One possible way you can use this feature is to make a password function that asks the user to enter in the correct password before time expires.

Optimizations

It's faster to do an operation on an entire list, than to do the same operation inside a seq( command. For example, take the following:


:seq(Y1(T),T,1,9
can be
:Y1(seq(T,T,1,9


However, not all commands that work for numbers will work for lists. A notable example is getting an element from a list: L1({1,2,3 will not return the first, second, and third elements of L1, so you will have to put the L1 inside the seq( command.

For this same reason, you shouldn't use a seq( command when you're really performing an operation on each element of a list. For example, if L1 has 10 elements:


:seq(L1(I)²,I,1,dim(L1
can be
:L1²


When generating a list of values incremented by a number i from i to a number N, seq( is not recommended as the amount of overhead on the command considerably slows the generation of the list. In cases where such a list is to be generated, it is beneficial to generate a list of a specific length, fill that list with the incrementer, and cumulatively sum each value in the list. For example, if a list of all the numbers between 1 and 500 were desired:


:500→dim(L1
:Fill(1,L1
:cumSum(L1→L1


This operation can be sped up even more using binomcdf(. For more information please visit the related pages.

A seq( command can replace a For( command, if all you're doing inside the For( command is storing to an element of a list. This will improve on both speed and size of your program. For example:


:For(I,1,10
:I²→L1(I
:End
can be
:seq(I²,I,1,10→L1


The seq( command itself can often be replaced with an unusual use of the Binomcdf( or Binompdf( commands, improving speed and sometimes size as well. However, this optimization is fairly advanced; read the pages for those commands to learn about it.


Error Conditions

  • ERR:ILLEGAL NEST is thrown if you try to use seq( inside of another seq( command.
  • ERR:DATA TYPE occurs when any of the inputted arguments are imaginary or complex.

Related Commands