1

Is there a way to skip some middle optional arguments? For example for this function:

f[{a_: 80, b_: 90}, {c_: 30, d_: 20}] := 
 Print["a=", a, ", b=", b, ", c=", c, ", d=", d]

Call something like this:

f[{(* empty or some symbols*), 3}, {4, 5}]

and get the result:

a=80, b=3, c=4, d=5

P.S. Function will have many parameters and will have complicated form, so the answer described here may be not applicable.

Tigran
  • 51
  • 2
  • 2
    You can prioritize certain arguments/argument sequences using Longest. Another option is to explicitly pass Automatic or similar to the function, and then do some preprocessing inside the function. But personally, I would strongly consider just passing in all values as named options in cases like these: Then it is trivial to skip arguments, and it is very clear which arguments are assigned for any given call – Lukas Lang Aug 18 '21 at 09:39
  • Thank you, Lukas, for your response. Can you please explain in more details? You mean I need to do something like presented here? – Tigran Aug 19 '21 at 16:36
  • 1
    yes exactly, something like that. – Lukas Lang Aug 19 '21 at 18:34

0 Answers0