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

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

Prime - local recursive function definition

StuartBruff
23-Emerald III

Prime - local recursive function definition

I've been trying to port a worksheet to Prime 1.0, but have got stuck because, whilst recursion is supported, local recursive function definition is giving me a problem. How does one define local function f to be recursive in the attached worksheet? Does it work in Prime 2.0?

Thanks,

Stuart

4 REPLIES 4

I think it is an error in Mathcad Prime 1.0 and 2.0 - see the picture

LocFuncRecursPrimeError.png

Спасибо, Валерий

In this instance (a worksheet I intend to post on filling matrices with implied polynomial data) I could easily rewrite the algorithm to avoid recursion, but there are many instances where this cannot be reasonably done.

Stuart

StuartBruff
23-Emerald III
(To:StuartBruff)

StuartBruff wrote:

I've been trying to port a worksheet to Prime 1.0, but have got stuck because, whilst recursion is supported, local recursive function definition is giving me a problem.   How does one define local function f to be recursive in the attached worksheet?  Does it work in Prime 2.0?

I've just been going through the process of updating my utility functions to try and make them work in both M15 and Prime 3.1.  Whilst converting a number of my worksheets I spent a good few minute painfully editing some functions to get them to work.   I'd forgotten about this particular problem, which turned out to be the source of my particular problems this time as well.   Rewriting these functions will be a pain, plus they lose the natural elegance of the recursive definition. 

I hope this 3 year old bug is in the pipeline to be fixed in Prime 4.0, along with restoration of currying (partial function application), the ability to pass a range definition as an argument to a function (eg, f(2..5)), re-definable global definitions and Math Styles (or equivalent) ... the lack of these capabilities is proving somewhat irritating.

It would be helpful if the Prime Converter:

converted an equation as best it could rather than, or in addition to, replacing it with an image of a non-convertible region.

extended a variable name with a Math Style name  (eg, func_MSU5 for function func defined in Math Style User 5) rather than convert to Variable ... this requires more attention to detail and effort than I'd like to manually separate converted functions with the same lexical name but differing Math Styles.

Stuart

StuartBruff
23-Emerald III
(To:StuartBruff)

Unfortunately, Prime still seems to lack the ability to define a local recursive function.

 

As I'm trying to write a few brief worksheets / articles on functional programming in Mathcad, this is adding to the problem of having to work around the lack of an empty array (not to mention having currying back would make life a lot easier!).

 

Are there any plans to fix this problem in, say, the next release of Prime ... 

 

Stuart

Announcements

Top Tags