Appendix A: Functions and Instructions 807
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
Define
progName
(
arg1Name, arg2Name, ...
) = Prgm
block
EndPrgm
Creates
progName
as a program or subprogram,
but cannot return a result using Return. 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)
without restrictions.
Note: It is usually easier to author and edit a
program block in the Program Editor rather than
on the entry line.
Define listinpt()=prgm:Local
n,i,str1,num:InputStr "Enter name of
list",str1:Input "No. of
elements",n:For i,1,n,1:Input
"element "&string(i),num:
num!#str1[i]:EndFor:EndPrgm ¸
Done
listinpt() ¸ Enter name of list
DelFold CATALOG
DelFold
folderName1
[,
folderName2
] [,
folderName3
] ...
Deletes user-defined folders with the names
folderName1, folderName2,
etc. An error message is
displayed if the folders contain any variables.
Note: You cannot delete the main folder.
NewFold games ¸ Done

(creates the folder games)

DelFold games
¸ Done

(deletes the folder games)