On the HP-50g, how does one convert an expression into a function programmatically? e.g. I have an expression x^2+1 and wish to convert it into the function << ->x 'x^2+1' >>. More generally, how does one return a program << ... etc... >> from a program? (Haven't hit on the proper syntax yet). Thanks for your assistance.

Appreciatively,

Chris

Quote:

On the HP-50g, how does one convert an expression into a function programmatically? e.g. I have an expression x^2+1 and wish to convert it into the function << ->x 'x^2+1' >>. More generally, how does one return a program << ... etc... >> from a program? (Haven't hit on the proper syntax yet). Thanks for your assistance.
Appreciatively,

Chris

One method is through strings. For example:

<< -> f << "<< -> x '" f + STR-> >>

could work, provided that the formula is in terms of lower-case 'x'. Enter a formula on the stack (with the single quotes) and evaluate this program to get the desired result. I don't remember if there is an RPL command that extracts the variable of a given expression (my bad memory thinks there is), but hopefully the example above gives you some ideas.

*Edited: 10 Dec 2013, 6:48 p.m. *

If you are trying to create mathematical functions, you can alternatively use the DEFINE command.