cancel
Showing results for
Did you mean:
cancel
Showing results for
Did you mean:

Community Tip - Need help navigating or using the PTC Community? Contact the community team. X

4-Participant

## Loop Conversion from MathCAD15 to Prime9 Variable Issue

When I ran the conversion tool it converted mathcad15 statement

to Prime 9 Statement

which only works if a precede it with an additional variable definition

Any ideas why this additional variable statement is required for Prime9 but not Mathcad15?

GregH
1 ACCEPTED SOLUTION

Accepted Solutions
23-Emerald III
(To:GregH)

What you are trying to do is equivalent to:

At the time of creation of the vector, it's element values are unknown.

I guess Prime was built as an even more lazy machine than Mathcad, although, in Mathcad this doesn't work either:

Success!
Luc

4 REPLIES 4
23-Emerald III
(To:GregH)

What you are trying to do is equivalent to:

At the time of creation of the vector, it's element values are unknown.

I guess Prime was built as an even more lazy machine than Mathcad, although, in Mathcad this doesn't work either:

Success!
Luc

4-Participant
(To:LucMeekes)

Hello Luc, thanks for the review and explanation. It makes sense to me that the vector creation was the issue. They must of handled it differently in MC15 with the if/otherwise statement. When Prime 9 did the conversion it changed this throughout the program to the new if/else format.

GregH
12-Amethyst
(To:GregH)

If I recall correctly, Mathcad 15 first checks the condition and then calculates the appropriate fork. The other fork is not handled at all and thus the error didn't happen. Prime checks both forks and sees the error.

24-Ruby V
(To:JKT)

@JKT wrote:

...

Prime checks both forks and sees the error.

Correct! On contrary to Mathcad, Prime does not use short-circuit evaluation (-> Short-circuit evaluation - Wikipedia).
Neither for boolean expressions nor for if-statements.

Here are two different ways to create the desired vector (I assume n to be a range running from 0 to N).

Even though the second approach is much shorter I would prefer the first one for better clarity and 'cause it does not need a range n to be defined (its replaced by the explicit internal for-loop). This for-loop allows the very same if-statement to work without an error on contrary to the usage of the range variable n (which is kind of an implicit loop).

Announcements
Top Tags