Programming 691
Initialize local variables
All local variables must be assigned an initial value before they are
referenced.
À 1 is stored as the initial value for m.
Note (CAS): Functions and programs cannot use a local variable to
perform symbolic calculations.
CAS: Performing symbolic calculations
If you want a function or program to perform symbolic calculations, you
must use a global variable instead of a local. However, you must be
certain that the global variable does not already exist outside of the
program. The following methods can help.
• Refer to a global variable name, typically with two or more
characters, that is not likely to exist outside of the function or
program.
•Include
DelVar within a program to delete the global variable, if it
exists, before referring to it. (DelVar does not delete locked or linked
variables.)
Differences between functions and programs
A function defined in the Program Editor is similar to the functions built
into the TI-Nspire™ Software.
• Functions must return a result, which can be graphed or entered in a
table. Programs cannot return a result.
• You can use a function (but not a program) within an expression. For
example:
3 ¦ func1(3) is valid, but not 3 ¦ prog1(3).
• You can run programs from Calculator and Notes applications only.
However, you can evaluate functions in Calculator, Notes, Lists &
Spreadsheet, Graphs & Geometry, and Data & Statistics.
Define fact(n)=Func
Local m: 1
&m À
While n>1
n
¦m&m: n–1&n
EndWhile
Return m
EndFunc