Page 21-58
The START…STEP construct
The general form of this statement is:
start_value end_value START program_statements increment
NEXT
The start_value, end_value, and
increment
of the loop index can be
positive or negative quantities. For
increment > 0
, execution occurs as
long as the index is less than or equal to
end_value
. For
increment < 0
,
execution occurs as long as the index is greater than or equal to
end_value
.
Example
– generating a list of values
Suppose that you want to generate a list of values of x from x = 0.5 to x =
6.5 in increments of 0.5. You can write the following program:
«
→
xs xe dx
«
xs DUP xe START DUP dx + dx STEP DROP xe
xs – dx / ABS 1 +
→
LIST
»
»
and store it in variable
@GLIST
.
In this program , xs = starting value of the loop, xe = ending value of the loop,
dx = increment value for loop. The program places values of xs, xs+dx,
xs+2
⋅
dx, xs+3
⋅
dx, … in the stack. Then, it calculates the number of elements
generated using the piece of code:
xe xs – dx / ABS 1. +
Finally, the program puts together a list with the elements placed in the stack.
•
Check out that the program call 0.5
`
2.5
`
0.5
`
@GLIST
produces the list {0.5 1. 1.5 2. 2.5}.
•
To see step-by-step operation use the program DBUG for a short list, for
example:
J
1
#
1.5
#
0.5
`
Enter parameters 1 1.5 0.5
[ ‘ ]
@GLIST
`
Enter the program name in level 1
„°LL
@)@RUN@ @@DBG@
Start the debugger.
Содержание 49g+
Страница 1: ...hp 49g graphing calculator user s guide H Edition 4 HP part number F2228 90006 ...
Страница 197: ...Page 5 30 LIN LNCOLLECT POWEREXPAND SIMPLIFY ...
Страница 377: ...Page 11 55 Function KER Function MKISOM ...
Страница 457: ...Page 13 26 In the right hand side figure above we are using the line editor to see the series expansion in detail ...
Страница 775: ...Page 26 10 the location of the backup battery in the top compartment at the back of the calculator ...
Страница 838: ...Page L 5 ...