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
Summary of Contents for Voyage 200
Page 36: ...Getting Started 36 D B D B Press Result ...
Page 45: ...Getting Started 45 3 0 D B D D B D Press Result ...
Page 46: ...Getting Started 46 D 2 0 0 2 D B Scroll down to October and press Press Result ...
Page 60: ...Getting Started 60 B D Press Result ...
Page 139: ...Previews 139 8 Complete the operation Press 2 d Steps and keystrokes Display 5 f 2 ...
Page 453: ...Differential Equation Graphing 453 ...
Page 468: ...Tables 468 ...
Page 777: ...Activities 777 ...