cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
New to using JMP? Hit the ground running with the Early User Edition of Discovery Summit. Register now, free of charge.
Register for our Discovery Summit 2024 conference, Oct. 21-24, where you’ll learn, connect, and be inspired.
Choose Language Hide Translation Bar
hogi
Level XI

User Defined Functions with Expression arguments

In JSL there are many functions which allow Expressions as arguments, like

 

dt << New Column( "X", Formula( row() ) );

 

where the supplementary argument Formula( row() ) can be at any position (N>1) within (...) because it can be identified via the keyword 

Formula().

 

Can user-defined functions have similar supplementary arguments?

 

 

2 REPLIES 2
Craige_Hales
Super User

Re: User Defined Functions with Expression arguments

No. The user defined function always evaluates the arguments that were passed before putting the values into its local parameters.

 

You could use expr(), but a list is a better choice: myfunc( "X", { formula( row() ) } ). I used that somewhere recently, and it worked well; variables inside the list still need to be evaluated, and myfunc finds them in the proper calling context. (Assuming no collisions between the caller names and myfunc names...) I think I used a single list and took advantage of nitems() as well.

Craige
hogi
Level XI

Re: User Defined Functions with Expression arguments

Thanks @Craige_Hales , the workaround with the list - brilliant

 

Hm, worth to write a post for the wish list?

Ah, there is one:
Keyword arguments for functions