EasyManua.ls Logo

HP HP-28S - Page 255

HP HP-28S
341 pages
To Next Page IconTo Next Page
To Next Page IconTo Next Page
To Previous Page IconTo Previous Page
To Previous Page IconTo Previous Page
Loading...
Techniques:
DO
...
UNTIL
...
END
(indefinite loop).
The
DO
clause contains
the
steps to
be
repeated;
the
UNTIL clause
contains
the
test
that
determines
whether
to
repeat
both
clauses again (if false)
or
to exit
(if true).
Programs
as
arguments.
Although
programs
are
commonly
named
and
then
executed
by
calling their
names,
programs
can
also
be
put
on
the
stack
and
used
as
arguments
to
other
programs.
Evaluation of local variables.
The
program
argument
to
be
executed
repeatedly
is
stored
in a local variable. It's
handy
to store
an
object
in a local variable
when
you
don't
know
beforehand
how
many
copies you'll
need.
MULTI
demonstrates
one
of
the
differences
between
global
and
lo-
cal variables: if a global variable contains a
name
or
program,
the
contents
of
the
variable are
evaluated
when
the
name
is evaluated;
but
the
contents
of a local variable are
always
simply recalled.
Con-
sequently, MULTI uses
the
local
name
to
put
the
program
argu-
ment
on
the
stack
and
then
executes
an
explicit
EVAL
command
to
evaluate
the
program.
Program
DO
DUP
F'
E',)AL
UtHIL
DUP
POT
::;At'1E
Comments
Begin
the
program.
Create
a local variable p
that
con-
tains
the
program
argument.
Begin
the
defining
program.
Begin
the
DO
clause.
Make
a
copy
of
the
object.
Apply
the
program
to
the
object,
returning
a
n~w
version. (The
EV
AL
command
is necessary to
execute
the
program
because
lo-
cal variables
always
return
their
contents
to
the
stack
unevaluated.)
Begin
the
UNTIL clause.
Make
a copy
of
the
new
version
of
the
object.
Move
the
old version to level
1.
Test
whether
the
old
version
and
the
new
version are
the
same.
254
28:
Programming
Examples

Table of Contents

Other manuals for HP HP-28S

Related product manuals