HP50g: Writing a function that returns a function - Printable Version +- HP Forums (https://archived.hpcalc.org/museumforum) +-- Forum: HP Museum Forums (https://archived.hpcalc.org/museumforum/forum-1.html) +--- Forum: Old HP Forum Archives (https://archived.hpcalc.org/museumforum/forum-2.html) +--- Thread: HP50g: Writing a function that returns a function (/thread-258358.html) HP50g: Writing a function that returns a function - Chris de Castro - 12-10-2013 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 Re: HP50g: Writing a function that returns a function - Han - 12-10-2013 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. Re: HP50g: Writing a function that returns a function - Han - 12-10-2013 If you are trying to create mathematical functions, you can alternatively use the DEFINE command.