Error, final value in for loop must be numeric or character
Description
Examples
The terminal condition in a for loop must be a numeric value, except when iterating over the letters in a string where a character is accepted.
Example 1
Note that n has no value.
for i from 1 to n do sinπ2⋅iend do;
Solution:
Define n to correct this error.
n≔4
n:=4
for i from 1 to n do sinπ2⋅iend do;
1
0
−1
Example 2
In this example x is set to 13−j where j has no value.
G≔procx local i≔1; to x do i≔i⋅x end do end proc:
G13−j
Error, (in G) final value in for loop must be numeric or character
As with the previous example, define j to correct this error.
j≔7
j:=7
46656
Example 3
Here N is not initialized to a numeric value.
for n to N−1 do xn+1 ≔ xn+Δxn; yn+1 ≔ yn+Δyn end do;
Initialize N.
N≔5
N:=5
x2:=x1+Δx⁡1
y2:=y1+Δy⁡1
x3:=x1+Δx⁡1+Δx⁡2
y3:=y1+Δy⁡1+Δy⁡2
x4:=x1+Δx⁡1+Δx⁡2+Δx⁡3
y4:=y1+Δy⁡1+Δy⁡2+Δy⁡3
x5:=x1+Δx⁡1+Δx⁡2+Δx⁡3+Δx⁡4
y5:=y1+Δy⁡1+Δy⁡2+Δy⁡3+Δy⁡4
See Also
loops
Download Help Document