Appendix A: Functions and Instructions 783
0b
binaryNumber
0h
hexadecimalNumber
Without a prefix,
integer1
is treated as decimal. The
result is displayed in decimal, regardless of the
Base
mode.
Define CATALOG
Define
funcName
(
arg1Name, arg2Name, ...
) =
expression
Creates
funcName
as a user-defined function. You
then can use
funcName
()
, just as you use built-in
functions
.
The function evaluates
expression
using
the supplied arguments and returns the result.
funcName
cannot be the name of a system variable
or built-in function.
The argument names are placeholders; you should
not use those same names as arguments when you
use the function.
Note: This form of
Define
is equivalent to executing
the expression:
expression
!
funcName
(
arg1Name,arg2Name
)
.
This command also can be used to define simple
variables; for example,
Define a=3
.
Define g(x,y)=2xì 3y
¸ Done
g(1,2)
¸ ë 4
1! a:2! b:g(a,b)
¸ ë 4
Define h(x)=when(x<2,2x-3,
ë 2x+3)
¸ Done
h(ë 3)
¸ ë 9
h(4)
¸ ë 5
Define eigenvl(a)=
cZeros(det(identity(dim(a)
[1])-xù a),x)
¸ Done
eigenvl([ë 1,2;4,3])
¸
{
2ø 3 - 1
11
ë (2ø
3 + 1)
11
}
Define
funcName
(
arg1Name, arg2Name, ...
) = Func
block
EndFunc
Is identical to the previous form of
Define
, except
that in this form, the user-defined function
funcName
()
can execute a block of multiple
statements.
block
can be either a single statement or a series of
statements separated with the “:” character.
block
also can include expressions and instructions (such
as
If
,
Then
,
Else
, and
For
). This allows the function
funcName
()
to use the
Return
instruction to return a
specific result.
Note: It is usually easier to author and edit this form
of Function in the program editor rather than on the
entry line.
Define g(x,y)=Func:If x>y Then
:Return x:Else:Return y:EndIf
:EndFunc
¸ Done
g(3,ë 7)
¸ 3
A binary number can have up to
32 digits. A hexadecimal number
can have up to 8.
Zero, not the letter O, followed by b or h.