home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Simtel MSDOS - Coast to Coast
/
simteldosarchivecoasttocoast2.iso
/
calculat
/
sm30a.zip
/
SYMBMATH.H14
< prev
next >
Wrap
Text File
|
1993-11-07
|
976b
|
37 lines
3.3.5 Loop
You can use two kinds of loops in SymbMath, fixed length
loops controlled by do() and variable-length loops controlled by
repeat(). The do() loop is similar to the FOR loop in BASIC language.
The control variable in the do() loops is not limited to
integer values. You can say:
do(f:=f+1, x from xmin to xmax step dx)
It is similar to
FOR x := xmin TO xmax STEP dx
f:=f+1
NEXT x
where xmin, xmax, and dx are real values. If STEP dx is omitted, it
defaults to 1.
e.g.
IN: x:=1
OUT: x := 1
IN: do(x:=x+1, j from 1 to 5 step 1)
OUT: x := 5
The conditional loops are probably more useful than the do()
loops if a number of iteration is unknown. It is
repeat(y until test)
repeat(y, test)
The word (until) can be replaced by comma ,.
The repeat() repeats to evaluate f until the test is true (i.e. the
result of the test is 1).
Example.
IN: x:=1
OUT: x := 1
IN: repeat(x:=x+1 until x>5)
OUT: x := 6