Texas Instruments TITANIUM TI-89 User Manual

Page 589

Advertising
background image

Programming

589

Note:

This example calculates the cube if

x

|

0

; otherwise, it returns a

0

.

The argument x is automatically treated as a local variable. However, if the example
needed another variable, the function would need to declare it as local by using the
Local command.

There is an implied

Return

at the end of the function. If the last line is not an expression,

an error occurs.

Example of a Function

Example of a Function

Example of a Function

Example of a Function

The following function returns the xth root of a value y

(

)

.

Two values must be passed

to the function: x and y.

Use

Return

. This is useful for

exiting a function and returning a
value at some point other than
the end of the function.

:cube(x)

:Func

:If x<0

: Return 0

:x^3

:EndFunc

y

x

Advertising