Thanks for the interest and comments, which clarify the options to make program techniques more robusts and clear in Mathcad. Some few notes.
= = = = = = = = = = = = = = = = = = = = = = = = = = = = = =
In Mathematica.
For[start, test, incr, body] executes start , then repeatedly evaluates body and incr until test fails to give True.
All parameters are mandatory. Don't looks pretty in text mode, the only one that I have to kernell access, and nor also in frontend, but works following "strick" rules.
= = = = = = = = = = = = = = = = = = = = = = = = = = = = = =
In Maple:
First syntax:
|for name | | from expr | | by expr | | to expr | | while expr | do statement sequence od;
Statment
> p := 0:
> for i from a to b do
> p := p+1;
> od: p;
gives 5 for a=1, b=5 and 0 for a=5, b=0
Also notice the nice inclusion of the while condition in the same line that for, very useful.
Second syntax:
|for name| |in expr| |while expr| do statement sequence od;
This looks actually more similar that what mathcad actually interpret the for loop. The expr is actually a maple object. Mathcad objects are ... very few: numbers, ranges or matrices.
= = = = = = = = = = = = = = = = = = = = = = = = = = = = = =
In MuPad.
Mathematica is only for completness, Maple for historical reasons, but given that MuPad is the Mathcad's kernel, could be more interesting. There are a lot of syntaxis
for i from start to stop do
body
end_for
for i from start to stop step stepwidth do
body
end_for
_for(i, start, stop, stepwidth, body)
for i from start downto stop do
body
end_for
for i from start downto stop step stepwidth do
body
end_for
_for_down(i, start, stop, stepwidth, body)
for x in object do
body
end_for
_for_in(x, object, body)
The underscores versions corresponds to the maple option to call this constructors as `for`( ... ). Note the inclution of the downto keyword (this is only a "to" with step negative).
There are not the beatifull while inline option.
The object constructor looks that is the same in Maple, and probably is the concept in Mathcad 14 to the for loop.
The above example in MuPad gives the same results as Maple answers, which diverges from the Mathcad considerations. I think that better to modify Mathcad answers could be the inclution of the some other avaible syntax.
Regards. Alvaro.