invalid loop - Maple Help

Online Help

All Products    Maple    MapleSim


Error, invalid loop

 

Description

Examples

Description

In Maple, for loops and while loops must be terminated with end do (or od). This error occurs when there is no end do or od statement to terminate the loop.

Examples

Example 1

In the following example, the for loop contains only a controlling clause, and does not contain an end do or od statement to terminate the loop.

for i from 1 to 3 do   

Error, invalid loop

Solution:

Complete the statement and add end do or od to the end of the loop.

for i from 1 to 3 do printi end do

1

2

3

(2.1)

 

Example 2
The following example contains a loop that is intended to return a floating-point approximation to the sine function at the angles (measured in degrees) in the list L. However, pressing Enter to insert line breaks (and not Shift + Enter) after the controlling clause in the for loop generates an error.

L  23.4, 87.2, 43.0, 99.7:

for i in L do

Error, invalid loop

Solution

To correct this error, press Shift + Enter to insert line breaks within the loop body instead of simply pressing Enter. Terminate the for loop with either an end do or an od statement.

L  23.4, 87.2, 43.0, 99.7:

for i in L do    evalfsini*Pi/180; end do;

0.3971478907

0.9988061374

0.6819983600

0.9857034691

(2.2)

See Also

do