It would be quite convenient if JMP allowed the Substitute() function to have an optional argument such as Substitute( ...., First Occurrence( 1 ) ) . This will help when passing arguments into a function by reference. Consider the following:
some function = Function( {_function, _args},
{Default Local},
function = Name Expr( _function );
Eval( Substitute( _args, {}, Expr( function ) ) )
);
other function = Function( {_1, _2, _3 = "optional"},
Show( _1, _2, _3 )
);
some function( Name Expr( other function ), {1, 2, 3} );
/* OUTPUT
_1 = 1;
_2 = 2;
_3 = 3;
*/
some function( Name Expr( other function ), {1, {2, 4}, 3} );
/* EXPECTED OUTPUT
_1 = 1;
_2 = {2, 4};
_3 = 3;
*/
Here in the first function I am calling a referenced function with a given argument list. The problem is that the Subsitute() replaces all lists with the function call, instead of the outer one only. This is where it would be nice to substitute only the first occurrence of the List() expression.
... View more