elseif x
≥
2 and x<3 then
f3(x)
else
f4(x)
endif
The nested-when() version looks like this:
when(x<
1
,f
1
(x),when(x<2,f2(x),when(x<3,f3(x),f4(x))))
The if...endif version is 107 bytes and executes in about 112 mS/call. The nested-when version is 73
bytes, and executes in about 100 mS/call. So, this method runs slightly faster and uses much less
memory.
[7.17] Returning more than one result from a function
Functions, by definition, can return only one result. You can get around this limitation by returning the
answers in a list, string, matrix or data variable. The calling routine must extract the individual answers
from the returned result. For example, to return the three results a, b and c, use
return {a,b,c}
then extract the individual results with
{a,b,c}[
1
]
to get a
{a,b,c}[2]
to get b
{a,b,c}[3]
to get c
Note that lists may contain not only numbers and expressions, but other lists and matrices if the
elements are expressed as equality expressions, for example
return {x=[
1
,2],y={3,4},z={5,6,w={7,8}}}
The assignment variables w, x, y and z must not exist in the current folder, or the expressions will be
evaluated and the list elements will becomre true or false. To retrieve the individual results, use the list
indices and the right() function. For example, if the list above is stored in the variable result, then
right(result[
1
])
returns [1,2]
right(result[2])
returns {3,4}
right(result[3])
returns {5,6,w={7,8}}
right(right(result[3])[3])
returns {7,8}
To minimize the chance that the assignment variables exist, you can use international characters. The
assignment variables need not be unique, for example, this works:
return {ä=[
1
,2],ä={3,4},ä={5,6,ä={7,8}}}
Another method to return more than one result is to use the results as arguments of an undefined user
function. For example, if your function uses
return udf(
1
0,20,{
1
,2,3})
then
7 - 17
Summary of Contents for TI-92+
Page 52: ...Component side of PCB GraphLink I O connector detail 1 41...
Page 53: ...LCD connector detail PCB switch side 1 42...
Page 54: ...Key pad sheet contact side Key pad sheet key side 1 43...
Page 55: ...Key cap detail 1 44...
Page 57: ...Component side of PCB with shield removed A detail view of the intergrated circuits 1 46...
Page 410: ...void extensionroutine2 void Credit to Bhuvanesh Bhatt 10 4...