I have the following function to create DownValues for some symbol when desired:
str = "p"; int = 5; SetAttributes[addDownValuesRuntime, HoldAll]; addDownValuesRuntime[func_Symbol, args__, body_] := With[{arg = Unevaluated[args]}, SetDelayed @@ Hold[func[arg], body] ];
If I make my function definition such that the args
are encapsulated by braces i.e. {str_String, int_Integer}
I note that the arguments for the defined function f
are also encapsulated by { }
:
addDownValuesRuntime[f, {str_String, int_Integer}, {str,int}]; ??f (* f[{str_String,int_Integer}]:= {str,int} *)
However, if I make my definition like this (args not encapsulated) then the args
are inside Sequence
and I cannot :
addDownValuesRuntime[f, str, int, {str,int}]; ??f (* f[Sequence[str,int]]:= {str,int} *)
In this case I cannot use the function.
My question is how to get rid of Sequence
such that my final function definition looks like f[str_String,int_Integer]:= body;
or f[str,int]:= body
Any help will be very much appreciated