Re: TIB: Back to TI-BASICs


[Prev][Next][Index][Thread]

Re: TIB: Back to TI-BASICs




Jody wrote:
[...]
> I didn't follow the function bit. What do use functions for? How does
> the function work?

A function is a restricted program designed to return a value.
Square root is a good example of this. You call SQRT with an input, and
it returns an output.
The only user-interaction when using functions is the initial input and
the final output.
An excerpt from the manual, p. 303:
Why Create a User-Defined Function?

Functions (as well as programs) are ideal for repetitive calculations or
tasks. You only need to write the function once. Then you can reuse it
as many times as necessary. Functions, however, have some advantages
over programs.

 - You can create functions that expand on the TI-92's built-in
functions. You can use the new functions same as any other function.

 - Functions return values that can be graphed or entered in a table.
Programs cannot.

 - You can use a function (but not a program) within an expression. For
example: 3*func1(3) is valid, but not 3*prog1(3).

 - Because you pass parameters to a function, you can write generic
functions that are not tied to specific variable names.

[...]

Differences Between Functions and Programs

[...]

 - Can refer to any variable; however, it can store a value to a local
variable only.

[...]

 - Cannot call a program as a subroutine, but it can call another
user-defined function.

 - Cannot define a program

 - Cannot define a global function, but it can define a local function.

(End)

I don't know if the 'define' command reffered to here is on the
TI-8x's...
It lets you define a program within your program, for example (p. 389):

Define g(x,y)=2x-3y <ENTER>
Done

[You can then call the function 'g', for example like this:]

g(1,2) <ENTER>
-4

-- 
          Rene Kragh Pedersen
------------------------------------------------------------------
man: Why did you get a divorce?
man:: Too many arguments.


Follow-Ups: References: