866 Appendix A: Functions and Instructions
Use an
undef
falseResult
to define an expression
that graphs only on an interval.
ClrGraph
¸
Graph when(x‚ë p and
x<0,x+3,undef)
¸
Omit only the
unknownResult
to define a two-piece
expression.
Graph when(x<0,x+3,5ì x^2)
¸
Nest
when()
to define expressions that have more
than two pieces.
@ "
H ¥ "
ClrGraph
¸ Done
Graph when(x<0,when(x<ë p,
4ù sin(x),2x+3),5ì x^2)
¸
when()
is helpful for defining recursive functions.
when(n>0,nù factoral(nì 1),1)
! factoral(n)
¸ Done
factoral(3)
¸ 6
3!
¸ 6
While CATALOG
While
condition
block
EndWhile
Executes the statements in
block
as long as
condition
is true.
block
can be either a single statement or a sequence
of statements separated with the “:” character.
Program segment:
©
:1! i
:0! temp
:While i<=20
: temp+1/i! temp
: i+1! i
:EndWhile
:Disp "sum of reciprocals up to
20",temp
©
“With” See |, page 885.