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

Community Tip - Did you get called away in the middle of writing a post? Don't worry you can find your unfinished post later in the Drafts section of your profile page. X

Convert function name to string?

23-Emerald II

Convert function name to string?

Noticing in Prime Express that evaluating a function name yields a string, ... 


2020 04 04 A.jpg

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)

23-Emerald III

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:



23-Emerald II

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, ...


2020 04 06 A.png

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 ...