Community email notifications are disrupted. While we are working to resolve, please check on your favorite boards regularly to keep up with your conversations and new topics.
Noticing in Prime Express that evaluating a function name yields a string, ...
I was wondering if anybody knows of a way to save that string to a variable?
(This is something that I asked for since about Mathcad 11 - it would have been quite handy to have when, say, evaluating a list of functions or identifying a function that's stored as an array element)
The obvious doesn't work:
Unfortunately the variable 'a' is NOT a string, as shown by:
(Complains that "This value must be a string")
Instead, a is now (also) the sine function:
Note: This works the same way in Mathcad 11:
Success!
Luc
Thanks, Luc.
I already tried your suggestion, even though I knew it wouldn't work (otherwise assigning functions to names wouldn't!!), but I was wondering if there was some operation that would do the job, eg, something along the lines of converting a range variable into a vector, ...
You might be able to do it in a program
name <--sin
return name
Constrained to Express, I can only speculate. . .
Hi Fred,
I hope it doesn't work! I frequently use(d) that particular form to generate and return constructed functions.
For example,
powgen(n) := f(x)<-n^x
p10 := powgen(10)
p10(3) = 1000
I've even used it within a program to iterate through a vector of functions to, say, compare their relative performance.
What we could possibly do with is a general purpose, Str(x), that converts its argument into a string regardless of of the argument's type. I wrote a version of Str that 'stringified' not just numbers, but also arrays as I had a need to exchange the data with another application, and also to be able to manipulate the data in its string form.
Unfortunately, I couldn't find a way to get Mathcad to return a string from a function.
Although having said that, I vaguely recall having found a way of doing it in M15 by playing with the xml. I might try finding my old M15 licence details ...
Stuart