cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
  • Don’t miss your chance to experience Discovery Summit Europe at our best available rate! Early bird registration through 31 Oct.
  • Graph Builder Toolbar streamlines interactive graphing. Creates shortcuts on Report and GraphBuilder Helpers toolbars. Download and install the extension.
  • JMP will suspend normal business operations for our Rest and Recharge Day on Friday, October 2, 2026.
    Regular business hours will resume on Monday, October 5, 2026.

Discussions

Solve problems, and share tips and tricks with other JMP users.
Choose Language Hide Translation Bar
Robbb
Level III

Copy of a function in JSL

Hi,

my function F is a complex function and in some cases I need to redefine it while keeping its old functionality. I would like to keep a copy of F before changing it. So far, I did not find a way to do this in JSL. Here is a small example, what I am trying to do. What is the correct way to really copy a function and not just link it?

Thanks!

F = Function( {x,y}, x+y ); // actually much more complex
Show(F(1,2)); // 3
// G = F; // Error, JMP complains about missing parameters
G = Function( {x,y}, F(x,y));
Show(G(1,2)); // 3
F = Function( {x,y}, x*y ); // Changes G, too.
Show(F(1,2)); // 2
Show(G(1,2)); // 2, but I want it to remain 3.

 

 

1 ACCEPTED SOLUTION

Accepted Solutions
ErraticAttack
Level VI

Re: Copy of a function in JSL

You can essentially grab the function pointer with the Name Expr() command

F = Function( {x,y}, x+y ); // actually much more complex
Show(F(1,2)); // 3
G = Name Expr( F ); // use the magic NameExpr function to grab a pointer
Show(G(1,2)); // 3
F = Function( {x,y}, x*y ); // Changes G, too.
Show(F(1,2)); // 2
Show(G(1,2)); // 2, but I want it to remain 3.

/*:
F(1, 2) = 3;
G(1, 2) = 3;
F(1, 2) = 2;
G(1, 2) = 3;
*/

 

Looks like there is an issue on this site preventing proper JSL code insertion

Jordan

View solution in original post

1 REPLY 1
ErraticAttack
Level VI

Re: Copy of a function in JSL

You can essentially grab the function pointer with the Name Expr() command

F = Function( {x,y}, x+y ); // actually much more complex
Show(F(1,2)); // 3
G = Name Expr( F ); // use the magic NameExpr function to grab a pointer
Show(G(1,2)); // 3
F = Function( {x,y}, x*y ); // Changes G, too.
Show(F(1,2)); // 2
Show(G(1,2)); // 2, but I want it to remain 3.

/*:
F(1, 2) = 3;
G(1, 2) = 3;
F(1, 2) = 2;
G(1, 2) = 3;
*/

 

Looks like there is an issue on this site preventing proper JSL code insertion

Jordan

Recommended Articles