HP50g: Writing a function that returns a function



#3

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


#4

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.


#5

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


Possibly Related Threads…
Thread Author Replies Views Last Post
  IFERR function on HP Prime Mic 2 1,880 12-02-2013, 01:33 AM
Last Post: cyrille de Brébisson
  Writing RPL programs on OS X Sean Freeman 18 5,374 11-30-2013, 03:59 PM
Last Post: Sean Freeman
  HP Prime: Dirichlet's eta function recognized but not numerically evaluated Helge Gabert 0 1,175 11-16-2013, 03:41 PM
Last Post: Helge Gabert
  Possible bug with sqrt function in the HP prime Michael de Estrada 6 2,599 11-15-2013, 12:49 PM
Last Post: Michael de Estrada
  HP-41 MCODE: The Last Function - at last! Ángel Martin 0 1,111 11-08-2013, 05:11 AM
Last Post: Ángel Martin
  [Prime] any ideas for a undo function? Stefan Dröge (Germany) 8 3,157 11-04-2013, 04:37 PM
Last Post: Damien
  [HP-Prime] - Shortcuts for program writing Jean-Michel 4 2,021 11-01-2013, 07:55 AM
Last Post: Jean-Michel
  HP Prime 'where' function bluesun08 11 3,494 10-29-2013, 06:56 PM
Last Post: Joe Horn
  HP Prime - Defining a function bluesun08 5 2,352 10-23-2013, 02:43 PM
Last Post: Han
  How to save the definition of a CAS program or CAS function ? dg1969 3 1,711 10-19-2013, 01:48 PM
Last Post: dg1969

Forum Jump: